firstly 0.0.16-next.2 → 0.1.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/esm/FF_Entity.d.ts +1 -1
- package/esm/FF_Entity.js +9 -9
- package/esm/ROUTES.d.ts +1 -1
- package/esm/ROUTES.js +2 -2
- package/esm/SqlDatabase/FF_LogToConsole.d.ts +14 -0
- package/esm/SqlDatabase/FF_LogToConsole.js +24 -5
- package/esm/auth/Entities.d.ts +2 -1
- package/esm/auth/Entities.js +18 -14
- package/esm/auth/server/AuthController.server.js +86 -93
- package/esm/auth/server/handleAuth.d.ts +4 -2
- package/esm/auth/server/handleAuth.js +8 -4
- package/esm/auth/server/helperRole.d.ts +11 -4
- package/esm/auth/server/helperRole.js +29 -20
- package/esm/auth/server/index.d.ts +1 -0
- package/esm/auth/server/index.js +1 -0
- package/esm/auth/server/module.d.ts +27 -5
- package/esm/auth/server/module.js +24 -10
- package/esm/auth/server/providers/github.js +13 -2
- package/esm/auth/static/assets/Page-BHW08QWz.css +1 -0
- package/esm/auth/static/assets/{Page-BorYIfy9.d.ts → Page-CTZPxniP.d.ts} +2 -2
- package/esm/auth/static/assets/Page-CTZPxniP.js +1 -0
- package/esm/auth/static/assets/{Page-CqsLm8yQ.d.ts → Page-D0d9iZO-.d.ts} +2 -2
- package/esm/auth/static/assets/{Page-CqsLm8yQ.js → Page-D0d9iZO-.js} +1 -1
- package/esm/auth/static/assets/{Page-Cm4MsdIa.d.ts → Page-DXshwJi7.d.ts} +2 -2
- package/esm/auth/static/assets/Page-DXshwJi7.js +20 -0
- package/esm/auth/static/assets/{index-Borxa2ns.d.ts → index-LRDptjak.d.ts} +3 -20
- package/esm/auth/static/assets/{index-Borxa2ns.js → index-LRDptjak.js} +2 -2
- package/esm/auth/static/index.html +1 -1
- package/esm/auth/types.d.ts +1 -0
- package/esm/bin/cmd.js +16 -16
- package/esm/changeLog/changeLogEntities.d.ts +21 -0
- package/esm/changeLog/changeLogEntities.js +57 -0
- package/esm/changeLog/index.d.ts +3 -15
- package/esm/changeLog/index.js +3 -51
- package/esm/changeLog/server/index.d.ts +39 -28
- package/esm/changeLog/server/index.js +40 -29
- package/esm/cron/Cron.d.ts +11 -0
- package/esm/cron/Cron.js +43 -0
- package/esm/cron/Role_Cron.d.ts +3 -0
- package/esm/cron/Role_Cron.js +3 -0
- package/esm/cron/index.d.ts +3 -0
- package/esm/cron/index.js +3 -0
- package/esm/cron/server/index.d.ts +29 -11
- package/esm/cron/server/index.js +29 -13
- package/esm/feedback/FeedbackController.d.ts +3 -1
- package/esm/feedback/FeedbackController.js +23 -1
- package/esm/feedback/server/index.d.ts +2 -2
- package/esm/feedback/server/index.js +2 -2
- package/esm/feedback/types.d.ts +6 -0
- package/esm/feedback/ui/DialogIssue.svelte +8 -1
- package/esm/feedback/ui/DialogIssues.svelte +1 -1
- package/esm/formats/index.d.ts +1 -1
- package/esm/formats/index.js +1 -1
- package/esm/formats/strings.d.ts +2 -0
- package/esm/formats/strings.js +22 -0
- package/esm/index.d.ts +1 -2
- package/esm/index.js +0 -2
- package/esm/mail/Mail.d.ts +13 -0
- package/esm/mail/Mail.js +51 -0
- package/esm/mail/Role_Mail.d.ts +3 -0
- package/esm/mail/Role_Mail.js +3 -0
- package/esm/mail/index.d.ts +7 -2
- package/esm/mail/index.js +7 -2
- package/esm/mail/server/formatMailHelper.d.ts +16 -0
- package/esm/mail/server/formatMailHelper.js +113 -0
- package/esm/mail/server/index.d.ts +32 -19
- package/esm/mail/server/index.js +113 -38
- package/esm/server/index.d.ts +9 -6
- package/esm/server/index.js +28 -50
- package/esm/svelte/FF_Layout.svelte +2 -2
- package/esm/svelte/dialog/DialogManagement.svelte +2 -2
- package/esm/svelte/helpers.d.ts +1 -0
- package/esm/svelte/index.d.ts +1 -0
- package/esm/svelte/index.js +1 -0
- package/esm/svelte/initRemultSvelteReactivity.d.ts +1 -0
- package/esm/svelte/initRemultSvelteReactivity.js +29 -0
- package/esm/sveltekit/server/index.d.ts +2 -2
- package/esm/sveltekit/server/index.js +2 -2
- package/esm/ui/Button.svelte +1 -1
- package/esm/ui/Field.svelte +5 -3
- package/esm/ui/Field.svelte.d.ts +4 -1
- package/esm/ui/FieldGroup.svelte +2 -1
- package/esm/ui/FieldGroup.svelte.d.ts +4 -1
- package/esm/ui/GridPaginate.svelte +2 -2
- package/esm/ui/GridPaginate2.svelte +1 -1
- package/esm/ui/Loading.svelte +1 -1
- package/esm/ui/Tooltip.svelte +1 -1
- package/esm/ui/dialog/DialogForm.svelte +3 -3
- package/esm/ui/dialog/DialogManagement.svelte +2 -2
- package/esm/ui/dialog/DialogPrimitive.svelte +2 -2
- package/esm/ui/dialog/FormEditAction.svelte +2 -2
- package/esm/ui/internals/FieldContainer.svelte +2 -2
- package/esm/ui/internals/Textarea.svelte +2 -2
- package/esm/ui/internals/select/MultiSelectMelt.svelte +6 -6
- package/esm/ui/internals/select/SelectMelt.svelte +28 -14
- package/esm/ui/internals/select/SelectMelt.svelte.d.ts +4 -1
- package/esm/ui/link/LinkPlus.svelte +2 -2
- package/esm/vite/index.js +50 -52
- package/package.json +15 -12
- package/esm/auth/static/assets/Page-BorYIfy9.js +0 -1
- package/esm/auth/static/assets/Page-Cm4MsdIa.js +0 -20
- package/esm/auth/static/assets/Page-JfNiCSIG.css +0 -1
- package/esm/mail/templates/DefaultMail.svelte +0 -86
- package/esm/mail/templates/DefaultMail.svelte.d.ts +0 -30
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { redirect } from '@sveltejs/kit';
|
|
1
|
+
import { redirect as redirectKit } from '@sveltejs/kit';
|
|
2
2
|
import { repo } from 'remult';
|
|
3
3
|
import { read } from '@kitql/internals';
|
|
4
4
|
import { FFAuthProvider } from '../Entities';
|
|
5
5
|
import { ff_createSession } from './helperFirstly';
|
|
6
6
|
import { getSafeOptions } from './module';
|
|
7
|
-
export const handleAuth = async ({ event, resolve }) => {
|
|
7
|
+
export const handleAuth = ({ redirect }) => async ({ event, resolve }) => {
|
|
8
8
|
const oSafe = getSafeOptions();
|
|
9
9
|
if (event.url.pathname === oSafe.firstlyData.props.ui?.paths?.verify_email) {
|
|
10
10
|
const token = event.url.searchParams.get('token') ?? '';
|
|
@@ -71,6 +71,8 @@ export const handleAuth = async ({ event, resolve }) => {
|
|
|
71
71
|
const redirectUrl = redirectUrlCookie ?? oSafe.redirectUrl;
|
|
72
72
|
if (!code || !state || !storedState || state !== storedState || !keyState) {
|
|
73
73
|
redirect(302, redirectUrl);
|
|
74
|
+
// We have to do this because "lib redirect" is not working, so I pass the handle... :(
|
|
75
|
+
throw 'we cannot arrive here!';
|
|
74
76
|
}
|
|
75
77
|
const selectedOAuth = oSafe.providers?.oAuths?.find((c) => c.name === keyState);
|
|
76
78
|
if (selectedOAuth && code) {
|
|
@@ -84,6 +86,7 @@ export const handleAuth = async ({ event, resolve }) => {
|
|
|
84
86
|
catch (error) {
|
|
85
87
|
console.error(error);
|
|
86
88
|
redirect(302, redirectUrl);
|
|
89
|
+
throw 'we cannot arrive here!';
|
|
87
90
|
}
|
|
88
91
|
if (!info.providerUserId) {
|
|
89
92
|
redirect(302, redirectUrl);
|
|
@@ -103,7 +106,7 @@ export const handleAuth = async ({ event, resolve }) => {
|
|
|
103
106
|
let nameToUse = '';
|
|
104
107
|
for (let i = 0; i < info.nameOptions.length; i++) {
|
|
105
108
|
const existingUser = await repo(oSafe.User).findOne({
|
|
106
|
-
where: {
|
|
109
|
+
where: { name: info.nameOptions[i] },
|
|
107
110
|
});
|
|
108
111
|
if (existingUser) {
|
|
109
112
|
// Don't do anything
|
|
@@ -117,7 +120,7 @@ export const handleAuth = async ({ event, resolve }) => {
|
|
|
117
120
|
nameToUse = `${info.nameOptions[0]}-${info.providerUserId}`;
|
|
118
121
|
}
|
|
119
122
|
const user = repo(oSafe.User).create();
|
|
120
|
-
user.
|
|
123
|
+
user.name = nameToUse;
|
|
121
124
|
await repo(oSafe.User).save(user);
|
|
122
125
|
account = repo(oSafe.Account).create();
|
|
123
126
|
account.provider = keyState;
|
|
@@ -127,6 +130,7 @@ export const handleAuth = async ({ event, resolve }) => {
|
|
|
127
130
|
account.lastVerifiedAt = new Date();
|
|
128
131
|
account.token = tokens.accessToken();
|
|
129
132
|
account.metadata = { ...info, tokens_data: tokens.data };
|
|
133
|
+
account.email = info.emailOptions.length > 0 ? info.emailOptions[0] : undefined;
|
|
130
134
|
await repo(oSafe.Account).save(account);
|
|
131
135
|
await ff_createSession(account.userId);
|
|
132
136
|
event.cookies.delete(`${keyState}_oauth_state`, { path: '/' });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { Log } from '@kitql/helpers';
|
|
3
|
-
import { FFAuthUser } from '../Entities';
|
|
1
|
+
import { type ClassType } from 'remult';
|
|
2
|
+
import type { Log } from '@kitql/helpers';
|
|
3
|
+
import { type FFAuthAccount, type FFAuthUser } from '../Entities';
|
|
4
4
|
/**
|
|
5
5
|
* will merge the roles and remove duplicates
|
|
6
6
|
* will return a new array & a status if the array was changed
|
|
@@ -9,4 +9,11 @@ export declare const mergeRoles: (existing: string[], newOnes: string[] | undefi
|
|
|
9
9
|
roles: string[];
|
|
10
10
|
changed: boolean;
|
|
11
11
|
};
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const linkRoleToUsersFromEnv: (o: {
|
|
13
|
+
log: Log;
|
|
14
|
+
accountEntity: ClassType<FFAuthAccount>;
|
|
15
|
+
userEntity: ClassType<FFAuthUser>;
|
|
16
|
+
envKey: string;
|
|
17
|
+
envValue: string;
|
|
18
|
+
roles: string[];
|
|
19
|
+
}) => Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { repo } from 'remult';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { nameify } from '../../formats';
|
|
3
|
+
import { cyan, green, yellow } from '@kitql/helpers';
|
|
4
|
+
import { FFAuthProvider } from '../Entities';
|
|
5
5
|
/**
|
|
6
6
|
* will merge the roles and remove duplicates
|
|
7
7
|
* will return a new array & a status if the array was changed
|
|
@@ -17,27 +17,36 @@ export const mergeRoles = (existing, newOnes) => {
|
|
|
17
17
|
}
|
|
18
18
|
return { roles: Array.from(result), changed };
|
|
19
19
|
};
|
|
20
|
-
export const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
export const linkRoleToUsersFromEnv = async (o) => {
|
|
21
|
+
const { log, accountEntity, userEntity, envKey, envValue, roles } = o;
|
|
22
|
+
const providersInfo = envValue === undefined
|
|
23
|
+
? []
|
|
24
|
+
: (envValue ?? '')
|
|
25
|
+
.split(',')
|
|
26
|
+
.map((c) => c.trim())
|
|
27
|
+
.filter(Boolean);
|
|
28
|
+
for (let i = 0; i < providersInfo.length; i++) {
|
|
29
|
+
const [providerUserId, provider] = providersInfo[i].split('|');
|
|
30
|
+
let a = await repo(accountEntity).findFirst({ providerUserId });
|
|
31
|
+
if (!a) {
|
|
32
|
+
const user = await repo(userEntity).upsert({ where: { roles, name: nameify(providerUserId) } });
|
|
33
|
+
a = await repo(accountEntity).insert({
|
|
34
|
+
providerUserId,
|
|
35
|
+
provider: provider ?? FFAuthProvider.PASSWORD.id,
|
|
36
|
+
userId: user.id,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
let user = await repo(userEntity).findFirst({ id: a.userId });
|
|
27
41
|
if (!user) {
|
|
28
|
-
user = repo(userEntity).create({
|
|
29
|
-
await repo(userEntity).save(user);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
if (!user.roles.includes(role)) {
|
|
33
|
-
user.roles.push(role);
|
|
34
|
-
await repo(userEntity).save(user);
|
|
35
|
-
}
|
|
42
|
+
user = repo(userEntity).create({ id: a.userId, name: nameify(providerUserId) });
|
|
36
43
|
}
|
|
44
|
+
user.roles = [...new Set([...user.roles, ...roles].sort())];
|
|
45
|
+
await repo(userEntity).save(user);
|
|
37
46
|
}
|
|
38
47
|
}
|
|
39
|
-
if (
|
|
40
|
-
log.info(`${cyan(envKey)}: ${
|
|
48
|
+
if (providersInfo.length > 0) {
|
|
49
|
+
log.info(`${cyan(envKey)}: ${providersInfo.map((c) => green(c.trim())).join(', ')} added via ${yellow(`.env`)}.`);
|
|
41
50
|
}
|
|
42
51
|
else {
|
|
43
52
|
log.info(`${cyan(envKey)}: No users added via ${yellow(`.env`)}.`);
|
|
@@ -2,6 +2,7 @@ import * as arctic from 'arctic';
|
|
|
2
2
|
import { handleAuth } from './handleAuth.js';
|
|
3
3
|
import { handleGuard } from './handleGuard.js';
|
|
4
4
|
export { auth, authModuleRaw } from './module';
|
|
5
|
+
export { linkRoleToUsersFromEnv as initRoleFromEnv } from './helperRole';
|
|
5
6
|
export { checkOAuthConfig } from './providers/helperProvider';
|
|
6
7
|
export { github } from './providers/github';
|
|
7
8
|
export { arctic, handleAuth, handleGuard };
|
package/esm/auth/server/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import * as arctic from 'arctic';
|
|
|
2
2
|
import { handleAuth } from './handleAuth.js';
|
|
3
3
|
import { handleGuard } from './handleGuard.js';
|
|
4
4
|
export { auth, authModuleRaw } from './module';
|
|
5
|
+
export { linkRoleToUsersFromEnv as initRoleFromEnv } from './helperRole';
|
|
5
6
|
export { checkOAuthConfig } from './providers/helperProvider';
|
|
6
7
|
export { github } from './providers/github';
|
|
7
8
|
export { arctic, handleAuth, handleGuard };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { OAuth2Tokens } from 'arctic';
|
|
2
2
|
import type { ClassType, UserInfo } from 'remult';
|
|
3
|
-
import {
|
|
3
|
+
import { ModuleFF } from '../../server';
|
|
4
4
|
import type { RecursivePartial } from '../../utils/types';
|
|
5
5
|
import { FFAuthAccount, FFAuthUser, FFAuthUserSession } from '../Entities';
|
|
6
6
|
import type { FirstlyData, FirstlyDataAuth, OAuth2UserInfo, ProviderAuthorizationURLOptions } from '../types';
|
|
7
|
-
import { initRoleFromEnv } from './helperRole';
|
|
8
7
|
export type FFOAuth2Provider<T = any, LitName extends string = string> = {
|
|
9
8
|
name: LitName;
|
|
10
9
|
caption: string;
|
|
@@ -23,6 +22,7 @@ type AuthOptions<TUserEntity extends FFAuthUser = FFAuthUser, TSessionEntity ext
|
|
|
23
22
|
ui?: false | RecursivePartial<FirstlyDataAuth['ui']>;
|
|
24
23
|
strings?: {
|
|
25
24
|
resetPasswordSend?: string;
|
|
25
|
+
resetPasswordUnknownUser?: string;
|
|
26
26
|
anErrorOccurred?: string;
|
|
27
27
|
cannotSignUp?: string;
|
|
28
28
|
};
|
|
@@ -54,6 +54,25 @@ type AuthOptions<TUserEntity extends FFAuthUser = FFAuthUser, TSessionEntity ext
|
|
|
54
54
|
email: string;
|
|
55
55
|
url: string;
|
|
56
56
|
}) => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* When defining this, you need to return a "manually constructed object" that will be used to send to the client.
|
|
59
|
+
* This is useful if you want to add some extra properties to the user object.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* transformDbUserToClientUser(session, user) {
|
|
64
|
+
* return {
|
|
65
|
+
* id: user.id,
|
|
66
|
+
* name: user.name,
|
|
67
|
+
* image: user.image ?? undefined,
|
|
68
|
+
* session: {
|
|
69
|
+
* id: session.id,
|
|
70
|
+
* expiresAt: session.expiresAt,
|
|
71
|
+
* },
|
|
72
|
+
* }
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
57
76
|
transformDbUserToClientUser?: (session: TSessionEntity, user: TUserEntity) => UserInfo;
|
|
58
77
|
providers?: {
|
|
59
78
|
demo?: {
|
|
@@ -127,6 +146,7 @@ type AuthOptions<TUserEntity extends FFAuthUser = FFAuthUser, TSessionEntity ext
|
|
|
127
146
|
};
|
|
128
147
|
oAuths?: FFOAuth2Provider[];
|
|
129
148
|
};
|
|
149
|
+
envRoles_AssignUsers?: Record<string, string>;
|
|
130
150
|
};
|
|
131
151
|
export declare let AUTH_OPTIONS: AuthOptions;
|
|
132
152
|
export declare const getSafeOptions: <TUserEntity extends FFAuthUser = FFAuthUser, TSessionEntity extends FFAuthUserSession = FFAuthUserSession, TAccountEntity extends FFAuthAccount = FFAuthAccount>() => {
|
|
@@ -229,6 +249,7 @@ export declare const getSafeOptions: <TUserEntity extends FFAuthUser = FFAuthUse
|
|
|
229
249
|
} | undefined;
|
|
230
250
|
strings: {
|
|
231
251
|
resetPasswordSend: string;
|
|
252
|
+
resetPasswordUnknownUser: string;
|
|
232
253
|
anErrorOccurred: string;
|
|
233
254
|
cannotSignUp: string;
|
|
234
255
|
};
|
|
@@ -260,14 +281,14 @@ export declare const getSafeOptions: <TUserEntity extends FFAuthUser = FFAuthUse
|
|
|
260
281
|
};
|
|
261
282
|
readonly customHtmlHead: string;
|
|
262
283
|
} | undefined;
|
|
284
|
+
envRoles_AssignUsers: Record<string, string>;
|
|
263
285
|
};
|
|
264
|
-
export declare const authModuleRaw:
|
|
286
|
+
export declare const authModuleRaw: ModuleFF;
|
|
265
287
|
/**
|
|
266
288
|
* To enable authentication in your app in a few lines of code.
|
|
267
289
|
* _Info: index: -777_
|
|
268
290
|
*/
|
|
269
|
-
export declare const auth: <TUserEntity extends FFAuthUser = FFAuthUser, TSessionEntity extends FFAuthUserSession = FFAuthUserSession, TAccountEntity extends FFAuthAccount = FFAuthAccount>(o: AuthOptions<TUserEntity, TSessionEntity, TAccountEntity>) =>
|
|
270
|
-
export { initRoleFromEnv };
|
|
291
|
+
export declare const auth: <TUserEntity extends FFAuthUser = FFAuthUser, TSessionEntity extends FFAuthUserSession = FFAuthUserSession, TAccountEntity extends FFAuthAccount = FFAuthAccount>(o: AuthOptions<TUserEntity, TSessionEntity, TAccountEntity>) => ModuleFF;
|
|
271
292
|
declare module 'remult' {
|
|
272
293
|
interface UserInfo {
|
|
273
294
|
session: {
|
|
@@ -276,3 +297,4 @@ declare module 'remult' {
|
|
|
276
297
|
};
|
|
277
298
|
}
|
|
278
299
|
}
|
|
300
|
+
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import bcrypt from 'bcryptjs';
|
|
2
2
|
import { EntityError, remult } from 'remult';
|
|
3
|
-
import { red } from '@kitql/helpers';
|
|
3
|
+
import { red, yellow } from '@kitql/helpers';
|
|
4
4
|
import { getRelativePackagePath } from '@kitql/internals';
|
|
5
|
+
import { env } from '$env/dynamic/private';
|
|
5
6
|
import { building } from '$app/environment';
|
|
6
7
|
import { AuthController } from '..';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { FF_Role_Auth, FFAuthAccount, FFAuthUser, FFAuthUserSession } from '../Entities';
|
|
8
|
+
import { ModuleFF } from '../../server';
|
|
9
|
+
import { FFAuthAccount, FFAuthUser, FFAuthUserSession } from '../Entities';
|
|
10
10
|
import { AuthControllerServer } from './AuthController.server';
|
|
11
11
|
import { validateSessionToken } from './helperDb';
|
|
12
12
|
import { setSessionTokenCookie } from './helperRemultServer';
|
|
13
|
-
import {
|
|
13
|
+
import { linkRoleToUsersFromEnv } from './helperRole';
|
|
14
14
|
export let AUTH_OPTIONS = { ui: {} };
|
|
15
15
|
const buildUrlOrDefault = (base, userSetting, fallback) => {
|
|
16
16
|
if (userSetting === false) {
|
|
@@ -103,7 +103,7 @@ export const getSafeOptions = () => {
|
|
|
103
103
|
transformDbUserToClientUserToUse = (session, user) => {
|
|
104
104
|
return {
|
|
105
105
|
id: user.id,
|
|
106
|
-
name: user.
|
|
106
|
+
name: user.name,
|
|
107
107
|
roles: user.roles,
|
|
108
108
|
session: {
|
|
109
109
|
id: session.id,
|
|
@@ -153,14 +153,17 @@ export const getSafeOptions = () => {
|
|
|
153
153
|
providers: AUTH_OPTIONS.providers,
|
|
154
154
|
strings: {
|
|
155
155
|
resetPasswordSend: AUTH_OPTIONS.strings?.resetPasswordSend ?? 'Mail sent ! You can now close this window.',
|
|
156
|
+
resetPasswordUnknownUser: AUTH_OPTIONS.strings?.resetPasswordUnknownUser ??
|
|
157
|
+
'If your email is registered, you will receive an email with a link to reset your password.',
|
|
156
158
|
anErrorOccurred: AUTH_OPTIONS.strings?.anErrorOccurred ?? 'An error occurred, contact the administrator.',
|
|
157
159
|
cannotSignUp: AUTH_OPTIONS.strings?.cannotSignUp ??
|
|
158
160
|
"You can't signup by yourself! Contact the administrator.",
|
|
159
161
|
},
|
|
160
162
|
ui,
|
|
163
|
+
envRoles_AssignUsers: AUTH_OPTIONS.envRoles_AssignUsers ?? {},
|
|
161
164
|
};
|
|
162
165
|
};
|
|
163
|
-
export const authModuleRaw = new
|
|
166
|
+
export const authModuleRaw = new ModuleFF({
|
|
164
167
|
name: 'auth',
|
|
165
168
|
priority: -777,
|
|
166
169
|
});
|
|
@@ -208,9 +211,20 @@ export const auth = (o) => {
|
|
|
208
211
|
}
|
|
209
212
|
};
|
|
210
213
|
authModuleRaw.initApi = async () => {
|
|
211
|
-
|
|
212
|
-
|
|
214
|
+
const oSafe = getSafeOptions();
|
|
215
|
+
for (const [key, value] of Object.entries(oSafe.envRoles_AssignUsers)) {
|
|
216
|
+
await linkRoleToUsersFromEnv({
|
|
217
|
+
log: authModuleRaw.log,
|
|
218
|
+
accountEntity: oSafe.Account,
|
|
219
|
+
userEntity: oSafe.User,
|
|
220
|
+
envKey: key.toUpperCase(),
|
|
221
|
+
envValue: env[key.toUpperCase()] ?? '',
|
|
222
|
+
roles: [value],
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
if (Object.entries(oSafe.envRoles_AssignUsers).length === 0 && AUTH_OPTIONS.debug) {
|
|
226
|
+
authModuleRaw.log.info(`set ${yellow('auth: { linkRoleToUsersFromEnv: ... }')} to assign roles to users via ${yellow('.env')}.`);
|
|
227
|
+
}
|
|
213
228
|
};
|
|
214
229
|
return authModuleRaw;
|
|
215
230
|
};
|
|
216
|
-
export { initRoleFromEnv };
|
|
@@ -59,18 +59,29 @@ export function github(options) {
|
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
61
|
const user = await res.json();
|
|
62
|
-
|
|
62
|
+
const nameOptions = [user.login];
|
|
63
|
+
const emailOptions = [];
|
|
64
|
+
if ((options?.authorizationURLOptions ?? ['user:email']).includes('user:email')) {
|
|
63
65
|
const res = await fetch('https://api.github.com/user/emails', {
|
|
64
66
|
headers: {
|
|
65
67
|
Authorization: `Bearer ${tokens.accessToken()}`,
|
|
66
68
|
},
|
|
67
69
|
});
|
|
68
70
|
user.emails = await res.json();
|
|
71
|
+
if (Array.isArray(user.emails)) {
|
|
72
|
+
const primaryEmails = user.emails.filter((email) => email.primary === true);
|
|
73
|
+
primaryEmails.forEach((email) => {
|
|
74
|
+
if (email.email) {
|
|
75
|
+
nameOptions.unshift(email.email);
|
|
76
|
+
emailOptions.unshift(email.email);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
69
80
|
}
|
|
70
81
|
if (options?.log) {
|
|
71
82
|
authModuleRaw.log.info(`user`, user);
|
|
72
83
|
}
|
|
73
|
-
return { raw: user, providerUserId: String(user.id), nameOptions
|
|
84
|
+
return { raw: user, providerUserId: String(user.id), nameOptions, emailOptions };
|
|
74
85
|
},
|
|
75
86
|
};
|
|
76
87
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.oauth-container.svelte-1dwkktf{display:flex;flex-direction:column;gap:.5rem}.oauth-button-icon.svelte-1dwkktf{width:1.25rem;height:1.25rem}.oauth-button.svelte-1dwkktf{display:flex;align-items:center;justify-content:center;gap:.5rem;padding:.5rem 1rem;font-size:.875rem;font-weight:500}form.svelte-skcj83{display:flex;flex-direction:column}h1.svelte-1jjivcr{text-align:center;margin-bottom:2rem}.wrapper.svelte-1jjivcr{min-height:100vh;display:flex;justify-content:center;align-items:center;margin:0 auto}.centered-layout.svelte-1jjivcr{display:flex;justify-content:center;align-items:center;width:100%}.split-layout.svelte-1jjivcr{display:flex;width:100%;min-height:100vh}.form-side.svelte-1jjivcr{width:50%;display:flex;justify-content:center;align-items:center}.image-side.svelte-1jjivcr{width:50%;height:100vh;overflow:hidden}.image-side.svelte-1jjivcr img:where(.svelte-1jjivcr){width:100%;height:100%;object-fit:cover}.form.svelte-1jjivcr{max-width:360px;width:100%;padding:1rem;display:flex;flex-direction:column}.form-footer.svelte-1jjivcr{margin-top:1rem;display:flex;flex-direction:column;justify-content:center;align-items:center}.fallback.svelte-1jjivcr{display:flex;justify-content:center;align-items:center}@media (max-width: 768px){.split-layout.svelte-1jjivcr{flex-direction:column}.form-side.svelte-1jjivcr{width:100%;order:2}.image-side.svelte-1jjivcr{width:100%;height:50vh;order:1}.form.svelte-1jjivcr{max-width:100%}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as r,E as l,ak as m,S as o,T as d,U as n,V as p,W as u,Y as i}from"./index-LRDptjak.js";p();a[u]="src/lib/modules/admin/Page.svelte";function a(e,s){r(new.target),l(s,!1,a);var t=m("Hello from admin");return o(e,t),d({...n()})}i(a);export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as r,E as l,
|
|
1
|
+
import{D as r,E as l,ak as o,S as m,T as p,U as u,V as d,W as f,Y as g}from"./index-LRDptjak.js";d();a[f]="src/lib/modules/storage/Page.svelte";function a(e,s){r(new.target),l(s,!1,a);var t=o("Hello from files");return m(e,t),p({...u()})}g(a);export{a as default};
|