chore(version): bump version to 2.12.2 and refactor password update logic
- Incremented version in package.json from 2.12.1 to 2.12.2. - Updated the UpdatePasswordPage component to utilize the new requireUser function for improved user session handling. - Refactored requireUser function to include a next parameter for redirecting after authentication failures, enhancing user experience. - Introduced a helper function getRedirectTo for cleaner redirect logic.
This commit is contained in:
@@ -30,11 +30,15 @@ type UserClaims = {
|
||||
* @name requireUser
|
||||
* @description Require a session to be present in the request
|
||||
* @param client
|
||||
* @param options
|
||||
* @param options.verifyMfa
|
||||
* @param options.next
|
||||
*/
|
||||
export async function requireUser(
|
||||
client: SupabaseClient,
|
||||
options?: {
|
||||
verifyMfa?: boolean;
|
||||
next?: string;
|
||||
},
|
||||
): Promise<
|
||||
| {
|
||||
@@ -60,7 +64,7 @@ export async function requireUser(
|
||||
return {
|
||||
data: null,
|
||||
error: new AuthenticationError(),
|
||||
redirectTo: SIGN_IN_PATH,
|
||||
redirectTo: getRedirectTo(SIGN_IN_PATH, options?.next),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -75,7 +79,7 @@ export async function requireUser(
|
||||
return {
|
||||
data: null,
|
||||
error: new MultiFactorAuthError(),
|
||||
redirectTo: MULTI_FACTOR_AUTH_VERIFY_PATH,
|
||||
redirectTo: getRedirectTo(MULTI_FACTOR_AUTH_VERIFY_PATH, options?.next),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -108,3 +112,7 @@ export class MultiFactorAuthError extends Error {
|
||||
super(`Multi-factor authentication required`);
|
||||
}
|
||||
}
|
||||
|
||||
function getRedirectTo(path: string, next?: string) {
|
||||
return path + (next ? `?next=${next}` : '');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user