diff --git a/src/logout/endpoint.ts b/src/logout/endpoint.ts deleted file mode 100644 index d657bfa..0000000 --- a/src/logout/endpoint.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Request, Response, NextFunction } from 'express' -import Joi from 'joi' - -import { fullMessagesResponse } from '../utils/joiSchemas' -import { MESSAGE_TYPE } from '../utils/enums' -import workflow from './workflow' -import { ErrorBuilder } from '../utils/ErrorBuilder' -import { customTFunction } from '../utils/translations' - -/** - * Logout endpoint request schema - empty - */ -export const requestSchema = Joi.object({ - body: Joi.object(), - query: Joi.object(), - params: Joi.object() -}) - -/** - * Logout endpoint response schema - full message - */ -export const responseSchema = fullMessagesResponse - -/** - * Logout endpoint - * Usage: `router.post('/logout', ApiAuth.guard(), schemaMiddleware(Logout.requestSchema), Logout.endpoint)` - * @param req - * @param res - * @param next - */ -export async function endpoint(req: Request, res: Response, next: NextFunction) { - try { - const authHeader = req.headers.authorization - - const t = req.t ?? customTFunction - if (!authHeader) { - throw new ErrorBuilder(401, t('Unauthorized')) - } - - await workflow(authHeader) - - return res.json({ - messages: [ - { - type: MESSAGE_TYPE.SUCCESS, - message: t('You were successfully logged out') - } - ] - }) - } catch (err) { - return next(err) - } -} diff --git a/src/logout/index.ts b/src/logout/index.ts index d25c66b..51d2f7a 100644 --- a/src/logout/index.ts +++ b/src/logout/index.ts @@ -1,4 +1,4 @@ -import workflow from './workflow' -import { endpoint, requestSchema, responseSchema } from './endpoint' +import runner from './runner' +import { workflow, requestSchema, responseSchema } from './workflow' -export { workflow, endpoint, requestSchema, responseSchema } +export { runner, workflow, requestSchema, responseSchema } diff --git a/src/logout/runner.ts b/src/logout/runner.ts new file mode 100644 index 0000000..61c6e39 --- /dev/null +++ b/src/logout/runner.ts @@ -0,0 +1,18 @@ +import jsonwebtoken from 'jsonwebtoken' + +import { IJwtPayload } from '../types/interfaces' +import { State } from '../State' + +/** + * Logout wokflow method, used in the `Logout.endpoint` + * Invalidates whole refresh token family. Access token is still valid after calling this endpoint. + * @param authHeader + */ +export default async function runner(authHeader: string) { + const [, accessToken] = authHeader.split(' ') + + // NOTE: token is valid, cause it already passed through verification (by passport) + const decodedAccessTokenData = jsonwebtoken.decode(accessToken) + + await State.getInstance().refreshTokenRepository.invalidateRefreshTokenFamily(decodedAccessTokenData.uid, decodedAccessTokenData.fid) +} diff --git a/src/logout/workflow.ts b/src/logout/workflow.ts index 7a0011d..5799b35 100644 --- a/src/logout/workflow.ts +++ b/src/logout/workflow.ts @@ -1,18 +1,53 @@ -import jsonwebtoken from 'jsonwebtoken' +import { Request, Response, NextFunction } from 'express' +import Joi from 'joi' -import { IJwtPayload } from '../types/interfaces' -import { State } from '../State' +import { fullMessagesResponse } from '../utils/joiSchemas' +import { MESSAGE_TYPE } from '../utils/enums' +import runner from './runner' +import { ErrorBuilder } from '../utils/ErrorBuilder' +import { customTFunction } from '../utils/translations' /** - * Logout wokflow method, used in the `Logout.endpoint` - * Invalidates whole refresh token family. Access token is still valid after calling this endpoint. - * @param authHeader + * Logout endpoint request schema - empty */ -export default async function workflow(authHeader: string) { - const [, accessToken] = authHeader.split(' ') +export const requestSchema = Joi.object({ + body: Joi.object(), + query: Joi.object(), + params: Joi.object() +}) - // NOTE: token is valid, cause it already passed through verification (by passport) - const decodedAccessTokenData = jsonwebtoken.decode(accessToken) +/** + * Logout endpoint response schema - full message + */ +export const responseSchema = fullMessagesResponse + +/** + * Logout endpoint + * Usage: `router.post('/logout', ApiAuth.guard(), schemaMiddleware(Logout.requestSchema), Logout.endpoint)` + * @param req + * @param res + * @param next + */ +export async function workflow(req: Request, res: Response, next: NextFunction) { + try { + const authHeader = req.headers.authorization + + const t = req.t ?? customTFunction + if (!authHeader) { + throw new ErrorBuilder(401, t('Unauthorized')) + } + + await runner(authHeader) - await State.getInstance().refreshTokenRepository.invalidateRefreshTokenFamily(decodedAccessTokenData.uid, decodedAccessTokenData.fid) + return res.json({ + messages: [ + { + type: MESSAGE_TYPE.SUCCESS, + message: t('You were successfully logged out') + } + ] + }) + } catch (err) { + return next(err) + } } diff --git a/src/logoutEverywhere/endpoint.ts b/src/logoutEverywhere/endpoint.ts deleted file mode 100644 index c69edc7..0000000 --- a/src/logoutEverywhere/endpoint.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Request, Response, NextFunction } from 'express' -import Joi from 'joi' - -import { fullMessagesResponse } from '../utils/joiSchemas' -import { MESSAGE_TYPE } from '../utils/enums' -import workflow from './workflow' -import { ErrorBuilder } from '../utils/ErrorBuilder' -import { customTFunction } from '../utils/translations' - -/** - * Logout from everywhere endpoint request schema - empty - */ -export const requestSchema = Joi.object({ - body: Joi.object(), - query: Joi.object(), - params: Joi.object() -}) - -/** - * Logout from everywhere endpoint response schema - full message - */ -export const responseSchema = fullMessagesResponse - -/** - * Logout from everywhere endpoint - * Usage: `router.post('/logout-everywhere', ApiAuth.guard(), schemaMiddleware(LogoutEverywhere.requestSchema), LogoutEverywhere.endpoint)` - * @param req - * @param res - * @param next - */ -export async function endpoint(req: Request, res: Response, next: NextFunction) { - try { - const authHeader = req.headers.authorization - - const t = req.t ?? customTFunction - if (!authHeader) { - throw new ErrorBuilder(401, t('Unauthorized')) - } - - await workflow(authHeader) - - return res.json({ - messages: [ - { - type: MESSAGE_TYPE.SUCCESS, - message: t('You were successfully logged out') - } - ] - }) - } catch (err) { - return next(err) - } -} diff --git a/src/logoutEverywhere/index.ts b/src/logoutEverywhere/index.ts index d25c66b..51d2f7a 100644 --- a/src/logoutEverywhere/index.ts +++ b/src/logoutEverywhere/index.ts @@ -1,4 +1,4 @@ -import workflow from './workflow' -import { endpoint, requestSchema, responseSchema } from './endpoint' +import runner from './runner' +import { workflow, requestSchema, responseSchema } from './workflow' -export { workflow, endpoint, requestSchema, responseSchema } +export { runner, workflow, requestSchema, responseSchema } diff --git a/src/logoutEverywhere/runner.ts b/src/logoutEverywhere/runner.ts new file mode 100644 index 0000000..ea65110 --- /dev/null +++ b/src/logoutEverywhere/runner.ts @@ -0,0 +1,24 @@ +import jsonwebtoken from 'jsonwebtoken' + +import { IJwtPayload } from '../types/interfaces' +import { State } from '../State' + +/** + * Logout from everywhere wokflow method, used in the `Logout.endpoint` + * Invalidates all user refresh tokens by calling `refreshTokenRepository.invalidateUserRefreshTokens`. If this method is not provided and this endpoint is used, library throws exception. + * All users access token are still valid after calling this endpoint. + * @param authHeader + */ +export default async function runner(authHeader: string) { + const [, accessToken] = authHeader.split(' ') + + // NOTE: token is valid, cause it already passed through verification (by passport) + const decodedAccessTokenData = jsonwebtoken.decode(accessToken) + + const state = State.getInstance() + if (!state.refreshTokenRepository.invalidateUserRefreshTokens) { + throw new Error("'invalidateUserRefreshTokens' is not implemented on UserTokenRepository") + } + + await state.refreshTokenRepository.invalidateUserRefreshTokens(decodedAccessTokenData.uid) +} diff --git a/src/logoutEverywhere/workflow.ts b/src/logoutEverywhere/workflow.ts index f675d0f..c462452 100644 --- a/src/logoutEverywhere/workflow.ts +++ b/src/logoutEverywhere/workflow.ts @@ -1,24 +1,53 @@ -import jsonwebtoken from 'jsonwebtoken' +import { Request, Response, NextFunction } from 'express' +import Joi from 'joi' -import { IJwtPayload } from '../types/interfaces' -import { State } from '../State' +import { fullMessagesResponse } from '../utils/joiSchemas' +import { MESSAGE_TYPE } from '../utils/enums' +import runner from './runner' +import { ErrorBuilder } from '../utils/ErrorBuilder' +import { customTFunction } from '../utils/translations' /** - * Logout from everywhere wokflow method, used in the `Logout.endpoint` - * Invalidates all user refresh tokens by calling `refreshTokenRepository.invalidateUserRefreshTokens`. If this method is not provided and this endpoint is used, library throws exception. - * All users access token are still valid after calling this endpoint. - * @param authHeader + * Logout from everywhere endpoint request schema - empty */ -export default async function workflow(authHeader: string) { - const [, accessToken] = authHeader.split(' ') +export const requestSchema = Joi.object({ + body: Joi.object(), + query: Joi.object(), + params: Joi.object() +}) - // NOTE: token is valid, cause it already passed through verification (by passport) - const decodedAccessTokenData = jsonwebtoken.decode(accessToken) +/** + * Logout from everywhere endpoint response schema - full message + */ +export const responseSchema = fullMessagesResponse - const state = State.getInstance() - if (!state.refreshTokenRepository.invalidateUserRefreshTokens) { - throw new Error("'invalidateUserRefreshTokens' is not implemented on UserTokenRepository") - } +/** + * Logout from everywhere endpoint + * Usage: `router.post('/logout-everywhere', ApiAuth.guard(), schemaMiddleware(LogoutEverywhere.requestSchema), LogoutEverywhere.endpoint)` + * @param req + * @param res + * @param next + */ +export async function workflow(req: Request, res: Response, next: NextFunction) { + try { + const authHeader = req.headers.authorization + + const t = req.t ?? customTFunction + if (!authHeader) { + throw new ErrorBuilder(401, t('Unauthorized')) + } - await state.refreshTokenRepository.invalidateUserRefreshTokens(decodedAccessTokenData.uid) + await runner(authHeader) + + return res.json({ + messages: [ + { + type: MESSAGE_TYPE.SUCCESS, + message: t('You were successfully logged out') + } + ] + }) + } catch (err) { + return next(err) + } } diff --git a/src/passwordReset/endpoint.ts b/src/passwordReset/endpoint.ts deleted file mode 100644 index dbd1e43..0000000 --- a/src/passwordReset/endpoint.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { Request, AuthRequest, Response, NextFunction } from 'express' -import Joi from 'joi' - -import { fullMessagesResponse, passwordSchema } from '../utils/joiSchemas' -import workflow from './workflow' -import { MESSAGE_TYPE } from '../utils/enums' -import { customTFunction } from '../utils/translations' - -/** - * Password reset request schema - password in the body - */ -export const requestSchema = Joi.object({ - body: Joi.object({ - password: passwordSchema - }), - query: Joi.object(), - params: Joi.object() -}) - -/** - * Password reset response schema - full message - */ -export const responseSchema = fullMessagesResponse - -/** - * Password reset endpoint. - * Usage: `router.post('/password-reset', PasswordReset.guard, schemaMiddleware(PasswordReset.requestSchema), PasswordReset.endpoint)` - * @param req - * @param res - * @param next - */ -export async function endpoint(req: Request, res: Response, next: NextFunction) { - try { - const { body, user } = req as AuthRequest - - await workflow(body.password, user.id) - - const t = req.t ?? customTFunction - return res.json({ - messages: [ - { - message: t('Password was successfully changed'), - type: MESSAGE_TYPE.SUCCESS - } - ] - }) - } catch (err) { - return next(err) - } -} diff --git a/src/passwordReset/index.ts b/src/passwordReset/index.ts index 95bb05e..f3e5974 100644 --- a/src/passwordReset/index.ts +++ b/src/passwordReset/index.ts @@ -1,7 +1,7 @@ import getToken from './getToken' import guard from './guard' -import { endpoint, requestSchema, responseSchema } from './endpoint' +import { workflow, requestSchema, responseSchema } from './workflow' import { strategy, strategyVerifyFunction, secretOrKeyProvider } from './strategy' -import workflow from './workflow' +import runner from './runner' -export { getToken, endpoint, requestSchema, responseSchema, guard, strategy, strategyVerifyFunction, secretOrKeyProvider, workflow } +export { getToken, requestSchema, responseSchema, guard, strategy, strategyVerifyFunction, secretOrKeyProvider, workflow, runner } diff --git a/src/passwordReset/runner.ts b/src/passwordReset/runner.ts new file mode 100644 index 0000000..dec69e5 --- /dev/null +++ b/src/passwordReset/runner.ts @@ -0,0 +1,19 @@ +import { createHash } from '../utils/jwt' +import { State } from '../State' +import { ID } from '../types/interfaces' + +/** + * Workflow method used in the `PasswordReset.endpoint`. + * Internally hashes user new password and subsequently call `userRepository.updateUserPassword` with this hash. + * It also invalidates all user refresh tokens, if `userRepository.invalidateUserRefreshTokens` method is provided. + * @param password + * @param userID + */ +export default async function runner(password: string, userID: ID): Promise { + const hash = await createHash(password) + + const state = State.getInstance() + await state.userRepository.updateUserPassword(userID, hash) + + await state.refreshTokenRepository.invalidateUserRefreshTokens?.(userID) +} diff --git a/src/passwordReset/workflow.ts b/src/passwordReset/workflow.ts index b3c27db..6054578 100644 --- a/src/passwordReset/workflow.ts +++ b/src/passwordReset/workflow.ts @@ -1,19 +1,50 @@ -import { createHash } from '../utils/jwt' -import { State } from '../State' -import { ID } from '../types/interfaces' +import { Request, AuthRequest, Response, NextFunction } from 'express' +import Joi from 'joi' + +import { fullMessagesResponse, passwordSchema } from '../utils/joiSchemas' +import runner from './runner' +import { MESSAGE_TYPE } from '../utils/enums' +import { customTFunction } from '../utils/translations' + +/** + * Password reset request schema - password in the body + */ +export const requestSchema = Joi.object({ + body: Joi.object({ + password: passwordSchema + }), + query: Joi.object(), + params: Joi.object() +}) + +/** + * Password reset response schema - full message + */ +export const responseSchema = fullMessagesResponse /** - * Workflow method used in the `PasswordReset.endpoint`. - * Internally hashes user new password and subsequently call `userRepository.updateUserPassword` with this hash. - * It also invalidates all user refresh tokens, if `userRepository.invalidateUserRefreshTokens` method is provided. - * @param password - * @param userID + * Password reset endpoint. + * Usage: `router.post('/password-reset', PasswordReset.guard, schemaMiddleware(PasswordReset.requestSchema), PasswordReset.endpoint)` + * @param req + * @param res + * @param next */ -export default async function workflow(password: string, userID: ID): Promise { - const hash = await createHash(password) +export async function workflow(req: Request, res: Response, next: NextFunction) { + try { + const { body, user } = req as AuthRequest - const state = State.getInstance() - await state.userRepository.updateUserPassword(userID, hash) + await runner(body.password, user.id) - await state.refreshTokenRepository.invalidateUserRefreshTokens?.(userID) + const t = req.t ?? customTFunction + return res.json({ + messages: [ + { + message: t('Password was successfully changed'), + type: MESSAGE_TYPE.SUCCESS + } + ] + }) + } catch (err) { + return next(err) + } } diff --git a/src/refreshToken/endpoint.ts b/src/refreshToken/endpoint.ts deleted file mode 100644 index 94b1a81..0000000 --- a/src/refreshToken/endpoint.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { NextFunction, Request, Response } from 'express' - -import Joi from 'joi' -import workflow from './workflow' - -/** - * Refresh Token Request Schema: - * `refreshToken` should be passed in body - */ -export const requestSchema = Joi.object({ - body: Joi.object({ - refreshToken: Joi.string().required() - }), - query: Joi.object(), - params: Joi.object() -}) - -/** - * refresh Token Response Schema: - * {`accessToken`, `refreshToken`} - */ -export const responseSchema = Joi.object({ - accessToken: Joi.string().required(), - refreshToken: Joi.string().required() -}) - -/** - * Endpoint for refreshing token - * Usage: `router.use('/refresh-token', schemaMiddleware(RefreshToken.requestSchema), RefreshToken.endpoint)` - * @param req - * @param res - * @param next - */ -export async function endpoint(req: Request, res: Response, next: NextFunction) { - try { - const { body } = req - - const tokens = await workflow(body.refreshToken, req) - - return res.json({ - ...tokens - }) - } catch (e) { - return next(e) - } -} diff --git a/src/refreshToken/index.ts b/src/refreshToken/index.ts index aad2092..e9e849f 100644 --- a/src/refreshToken/index.ts +++ b/src/refreshToken/index.ts @@ -1,3 +1,3 @@ -import { endpoint, requestSchema, responseSchema } from './endpoint' +import { workflow, requestSchema, responseSchema } from './workflow' -export { endpoint, requestSchema, responseSchema } +export { workflow, requestSchema, responseSchema } diff --git a/src/refreshToken/runner.ts b/src/refreshToken/runner.ts new file mode 100644 index 0000000..0a12f67 --- /dev/null +++ b/src/refreshToken/runner.ts @@ -0,0 +1,50 @@ +import { Request } from 'express' + +import { verifyRefreshJWT } from '../utils/jwt' +import { State } from '../State' +import { ErrorBuilder } from '../utils/ErrorBuilder' +import { getTokens } from '../login' +import { ILoginResponse } from '../login/getTokens' +import { customTFunction } from '../utils/translations' + +/** + * Method used in the `RefreshToken.endpoint` + * Internally decodes (and validates) refresh token. If the token is not valid `refreshTokenRepository.invalidateRefreshTokenFamily` is called - which invalidates all refresh tokens ranted based on same login event + * When token is valid, user is fetched using `userRepository.getUserById`. Again, when no user is returned whole refresh token family is invalidated. + * Refresh token is then invalidated, but new access and refresh tokens are generated + * return new access and refresh tokens - refresh token is passed as parameter to the `refreshTokenRepository.saveRefreshToken` method + * @param refreshToken + * @param req + */ +export default async function runner(refreshToken: string, req: Request): Promise { + const t = req.t ?? customTFunction + // decode refresh token + const decodedRefreshTokenData = await verifyRefreshJWT(refreshToken, t) + + const state = State.getInstance() + const { refreshTokenRepository, userRepository } = state + // find if the token si valid + const isTokenValid = await refreshTokenRepository.isRefreshTokenValid(decodedRefreshTokenData.uid, decodedRefreshTokenData.fid, decodedRefreshTokenData.jti) + + if (!isTokenValid) { + // invalidate refresh token family and if possible also access tokens + await refreshTokenRepository.invalidateRefreshTokenFamily(decodedRefreshTokenData.uid, decodedRefreshTokenData.fid) + + throw new ErrorBuilder(401, t('error:Refresh token is not valid')) + } + + // check if the user exists + const user = await userRepository.getUserById(`${decodedRefreshTokenData.uid}`) + + if (!user) { + // invalidate refresh token family (all tokens granted from single login action) + await refreshTokenRepository.invalidateRefreshTokenFamily(decodedRefreshTokenData.uid, decodedRefreshTokenData.fid) + + throw new ErrorBuilder(401, t('error:Refresh token is not valid')) + } + + // refresh token rotation - invalidate already used token + await refreshTokenRepository.invalidateRefreshToken(decodedRefreshTokenData.uid, decodedRefreshTokenData.fid, decodedRefreshTokenData.jti) + + return getTokens(user.id, decodedRefreshTokenData.fid) +} diff --git a/src/refreshToken/workflow.ts b/src/refreshToken/workflow.ts index 9986b41..853c5fa 100644 --- a/src/refreshToken/workflow.ts +++ b/src/refreshToken/workflow.ts @@ -1,50 +1,46 @@ -import { Request } from 'express' +import { NextFunction, Request, Response } from 'express' -import { verifyRefreshJWT } from '../utils/jwt' -import { State } from '../State' -import { ErrorBuilder } from '../utils/ErrorBuilder' -import { getTokens } from '../login' -import { ILoginResponse } from '../login/getTokens' -import { customTFunction } from '../utils/translations' +import Joi from 'joi' +import runner from './runner' /** - * Method used in the `RefreshToken.endpoint` - * Internally decodes (and validates) refresh token. If the token is not valid `refreshTokenRepository.invalidateRefreshTokenFamily` is called - which invalidates all refresh tokens ranted based on same login event - * When token is valid, user is fetched using `userRepository.getUserById`. Again, when no user is returned whole refresh token family is invalidated. - * Refresh token is then invalidated, but new access and refresh tokens are generated - * return new access and refresh tokens - refresh token is passed as parameter to the `refreshTokenRepository.saveRefreshToken` method - * @param refreshToken - * @param req + * Refresh Token Request Schema: + * `refreshToken` should be passed in body */ -export default async function workflow(refreshToken: string, req: Request): Promise { - const t = req.t ?? customTFunction - // decode refresh token - const decodedRefreshTokenData = await verifyRefreshJWT(refreshToken, t) - - const state = State.getInstance() - const { refreshTokenRepository, userRepository } = state - // find if the token si valid - const isTokenValid = await refreshTokenRepository.isRefreshTokenValid(decodedRefreshTokenData.uid, decodedRefreshTokenData.fid, decodedRefreshTokenData.jti) - - if (!isTokenValid) { - // invalidate refresh token family and if possible also access tokens - await refreshTokenRepository.invalidateRefreshTokenFamily(decodedRefreshTokenData.uid, decodedRefreshTokenData.fid) +export const requestSchema = Joi.object({ + body: Joi.object({ + refreshToken: Joi.string().required() + }), + query: Joi.object(), + params: Joi.object() +}) - throw new ErrorBuilder(401, t('error:Refresh token is not valid')) - } +/** + * refresh Token Response Schema: + * {`accessToken`, `refreshToken`} + */ +export const responseSchema = Joi.object({ + accessToken: Joi.string().required(), + refreshToken: Joi.string().required() +}) - // check if the user exists - const user = await userRepository.getUserById(`${decodedRefreshTokenData.uid}`) +/** + * Endpoint for refreshing token + * Usage: `router.use('/refresh-token', schemaMiddleware(RefreshToken.requestSchema), RefreshToken.endpoint)` + * @param req + * @param res + * @param next + */ +export async function workflow(req: Request, res: Response, next: NextFunction) { + try { + const { body } = req - if (!user) { - // invalidate refresh token family (all tokens granted from single login action) - await refreshTokenRepository.invalidateRefreshTokenFamily(decodedRefreshTokenData.uid, decodedRefreshTokenData.fid) + const tokens = await runner(body.refreshToken, req) - throw new ErrorBuilder(401, t('error:Refresh token is not valid')) + return res.json({ + ...tokens + }) + } catch (e) { + return next(e) } - - // refresh token rotation - invalidate already used token - await refreshTokenRepository.invalidateRefreshToken(decodedRefreshTokenData.uid, decodedRefreshTokenData.fid, decodedRefreshTokenData.jti) - - return getTokens(user.id, decodedRefreshTokenData.fid) } diff --git a/tests/cases/logout/helpers.ts b/tests/cases/logout/helpers.ts index 9489dd4..bb2f7ee 100644 --- a/tests/cases/logout/helpers.ts +++ b/tests/cases/logout/helpers.ts @@ -15,8 +15,8 @@ import * as enTranslations from '../../../locales/en/translation.json' export function setupRouters(app: Express) { const loginRouter = LoginRouter() - loginRouter.post('/logout', ApiAuth.guard(), schemaMiddleware(Logout.requestSchema), Logout.endpoint) - loginRouter.post('/refresh-token', schemaMiddleware(RefreshToken.requestSchema), RefreshToken.endpoint) + loginRouter.post('/logout', ApiAuth.guard(), schemaMiddleware(Logout.requestSchema), Logout.workflow) + loginRouter.post('/refresh-token', schemaMiddleware(RefreshToken.requestSchema), RefreshToken.workflow) app.use('/auth', loginRouter) diff --git a/tests/cases/logoutEverywhere/logoutEverywhere.test.ts b/tests/cases/logoutEverywhere/logoutEverywhere.test.ts index 031fb5c..3d4316c 100644 --- a/tests/cases/logoutEverywhere/logoutEverywhere.test.ts +++ b/tests/cases/logoutEverywhere/logoutEverywhere.test.ts @@ -39,8 +39,8 @@ function getLogoutMessage(language?: string): string { function setupRouters() { const loginRouter = LoginRouter() - loginRouter.post('/logout-everywhere', ApiAuth.guard(), schemaMiddleware(LogoutEverywhere.requestSchema), LogoutEverywhere.endpoint) - loginRouter.post('/refresh-token', schemaMiddleware(RefreshToken.requestSchema), RefreshToken.endpoint) + loginRouter.post('/logout-everywhere', ApiAuth.guard(), schemaMiddleware(LogoutEverywhere.requestSchema), LogoutEverywhere.workflow) + loginRouter.post('/refresh-token', schemaMiddleware(RefreshToken.requestSchema), RefreshToken.workflow) app.use('/auth', loginRouter) diff --git a/tests/cases/passwordReset/helpers.ts b/tests/cases/passwordReset/helpers.ts index ed226cd..85e2d62 100644 --- a/tests/cases/passwordReset/helpers.ts +++ b/tests/cases/passwordReset/helpers.ts @@ -43,7 +43,7 @@ export async function getPasswordToken(email: string): Promise { export function setupRouters(app: Express) { const userRouter = Router() - userRouter.post('/password-reset', PasswordReset.guard, schemaMiddleware(PasswordReset.requestSchema), PasswordReset.endpoint) + userRouter.post('/password-reset', PasswordReset.guard, schemaMiddleware(PasswordReset.requestSchema), PasswordReset.workflow) app.use('/user', userRouter) diff --git a/tests/cases/refreshToken/refreshToken.test.ts b/tests/cases/refreshToken/refreshToken.test.ts index ec7dcde..4090073 100644 --- a/tests/cases/refreshToken/refreshToken.test.ts +++ b/tests/cases/refreshToken/refreshToken.test.ts @@ -65,7 +65,7 @@ before(async () => { function setupRouters() { const loginRouter = LoginRouter() - loginRouter.post('/refresh-token', schemaMiddleware(RefreshToken.requestSchema), RefreshToken.endpoint) + loginRouter.post('/refresh-token', schemaMiddleware(RefreshToken.requestSchema), RefreshToken.workflow) app.use('/auth', loginRouter)