feat(auth): refactor authentication routes and enhance JWT handling
- Removed unused permission and app retrieval logic from the login process. - Introduced a new endpoint for reissuing access tokens to handle role changes and account switches. - Updated JWT payload handling to improve clarity and maintainability. - Enhanced the readJwtPayload function for better decoding of JWT claims.
This commit is contained in:
1 parent
ed1699503a
commit
09ed7f4dc4
9 files changed
+206
-84
No files matched your search
@@ -6,7 +6,7 @@ import {
|
||||
type UserRow,
|
||||
} from '@authportal/db'
|
||||
import type { AppId, MeResponse } from '@authportal/shared'
|
||||
import { APP_IDS, normalizePermissionKeys } from '@authportal/shared'
|
||||
import { APP_IDS, allPermissionKeys, normalizePermissionKeys } from '@authportal/shared'
|
||||
|
||||
export type AuthUser = {
|
||||
id: string
|
||||
@@ -72,9 +72,12 @@ export function loadAuthUser(
|
||||
user: UserRow,
|
||||
): AuthUser {
|
||||
const apps = getUserApps(request.server.db, user.id)
|
||||
const permissions = normalizePermissionKeys(
|
||||
let permissions = normalizePermissionKeys(
|
||||
getUserPermissions(request.server.db, user.id),
|
||||
)
|
||||
if (user.isAdmin) {
|
||||
permissions = allPermissionKeys()
|
||||
}
|
||||
return {
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
|
||||
Reference in new issue
Block a user