admin) User management admin page (#35)
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m20s
All checks were successful
Build and Push Image / docker-build-and-push (push) Successful in 2m20s
Reviewed-on: #35 Reviewed-by: shaun <shaun@campbellwireless.net> Co-authored-by: AI Agent <ai-agent@campbellwireless.net> Co-committed-by: AI Agent <ai-agent@campbellwireless.net>
This commit was merged in pull request #35.
This commit is contained in:
21
src/auth.ts
21
src/auth.ts
@@ -1,5 +1,6 @@
|
||||
import { SvelteKitAuth } from '@auth/sveltekit';
|
||||
import { env } from '$env/dynamic/private';
|
||||
import { upsertUserFromAuth } from '$lib/server/users.js';
|
||||
|
||||
export const { handle, signIn, signOut } = SvelteKitAuth({
|
||||
providers: [
|
||||
@@ -23,7 +24,25 @@ export const { handle, signIn, signOut } = SvelteKitAuth({
|
||||
trustHost: true,
|
||||
callbacks: {
|
||||
jwt({ token, profile }) {
|
||||
if (profile?.sub) token.sub = profile.sub as string;
|
||||
const details = profile as
|
||||
| {
|
||||
sub?: string;
|
||||
name?: string;
|
||||
email?: string;
|
||||
username?: string;
|
||||
preferred_username?: string;
|
||||
}
|
||||
| undefined;
|
||||
if (details?.sub) {
|
||||
token.sub = details.sub as string;
|
||||
upsertUserFromAuth({
|
||||
id: details.sub,
|
||||
username: details.username ?? details.preferred_username ?? details.name,
|
||||
fullName: details.name ?? details.username ?? details.preferred_username,
|
||||
email: details.email,
|
||||
authSource: 'OIDC - Synology'
|
||||
});
|
||||
}
|
||||
return token;
|
||||
},
|
||||
session({ session, token }) {
|
||||
|
||||
Reference in New Issue
Block a user