1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-03-23 10:45:08 +00:00

feat: add support for email verification (#1223)

This commit is contained in:
Elias Schneider
2026-01-11 12:31:26 +01:00
committed by GitHub
parent e955118a6f
commit 1e7442f5df
60 changed files with 1452 additions and 700 deletions

View File

@@ -2,7 +2,8 @@ import type { User } from '$lib/types/user.type';
// Returns the path to redirect to based on the current path and user authentication status
// If no redirect is needed, it returns null
export function getAuthRedirectPath(path: string, user: User | null) {
export function getAuthRedirectPath(url: URL, user: User | null) {
const path = url.pathname;
const isSignedIn = !!user;
const isAdmin = user?.isAdmin;
@@ -19,7 +20,8 @@ export function getAuthRedirectPath(path: string, user: User | null) {
const isAdminPath = path == '/settings/admin' || path.startsWith('/settings/admin/');
if (!isUnauthenticatedOnlyPath && !isPublicPath && !isSignedIn) {
return '/login';
const redirect = url.pathname + url.search;
return `/login?redirect=${encodeURIComponent(redirect)}`;
}
if (isUnauthenticatedOnlyPath && isSignedIn) {
@@ -29,4 +31,6 @@ export function getAuthRedirectPath(path: string, user: User | null) {
if (isAdminPath && !isAdmin) {
return '/settings';
}
return null;
}