mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 01:01:49 +10:00
fix: migrate 2fa to custom auth
This commit is contained in:
@ -8,7 +8,6 @@ import { validateSessionToken } from '../session/session';
|
||||
import { getSessionCookie } from '../session/session-cookies';
|
||||
|
||||
export const getSession = async (c: Context | Request): Promise<SessionValidationResult> => {
|
||||
// Todo: Make better
|
||||
const sessionId = await getSessionCookie(mapRequestToContextForCookie(c));
|
||||
|
||||
if (!sessionId) {
|
||||
@ -29,7 +28,6 @@ export const getRequiredSession = async (c: Context | Request) => {
|
||||
return { session, user };
|
||||
}
|
||||
|
||||
// Todo: Test if throwing errors work
|
||||
if (c instanceof Request) {
|
||||
throw new Error('Unauthorized');
|
||||
}
|
||||
@ -37,9 +35,11 @@ export const getRequiredSession = async (c: Context | Request) => {
|
||||
throw new AppError(AuthenticationErrorCode.Unauthorized);
|
||||
};
|
||||
|
||||
/**
|
||||
* Todo: Rethink, this is pretty sketchy.
|
||||
*/
|
||||
const mapRequestToContextForCookie = (c: Context | Request) => {
|
||||
if (c instanceof Request) {
|
||||
// c.req.raw.headers.
|
||||
const partialContext = {
|
||||
req: {
|
||||
raw: c,
|
||||
|
||||
Reference in New Issue
Block a user