From 055cfb11a9d688dbc2dce5c164d1f0b311918378 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 27 Apr 2020 10:19:14 +0200 Subject: Add plugin auth migrations --- server/lib/auth.ts | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'server/lib/auth.ts') diff --git a/server/lib/auth.ts b/server/lib/auth.ts index c2a6fcaff..c47ec62d0 100644 --- a/server/lib/auth.ts +++ b/server/lib/auth.ts @@ -126,26 +126,30 @@ async function proxifyPasswordGrant (req: express.Request, res: express.Response authOptions.authName, pluginAuth.npmName, loginOptions.id, authOptions.getWeight() ) - const loginResult = await authOptions.login(loginOptions) - if (loginResult) { - logger.info( - 'Login success with auth method %s of plugin %s for %s.', - authOptions.authName, pluginAuth.npmName, loginOptions.id - ) - - res.locals.bypassLogin = { - bypass: true, - pluginName: pluginAuth.npmName, - authName: authOptions.authName, - user: { - username: loginResult.username, - email: loginResult.email, - role: loginResult.role || UserRole.USER, - displayName: loginResult.displayName || loginResult.username + try { + const loginResult = await authOptions.login(loginOptions) + if (loginResult) { + logger.info( + 'Login success with auth method %s of plugin %s for %s.', + authOptions.authName, pluginAuth.npmName, loginOptions.id + ) + + res.locals.bypassLogin = { + bypass: true, + pluginName: pluginAuth.npmName, + authName: authOptions.authName, + user: { + username: loginResult.username, + email: loginResult.email, + role: loginResult.role || UserRole.USER, + displayName: loginResult.displayName || loginResult.username + } } - } - return + return + } + } catch (err) { + logger.error('Error in auth method %s of plugin %s', authOptions.authName, pluginAuth.npmName, { err }) } } } -- cgit v1.2.3