diff options
Diffstat (limited to 'server/lib/auth.ts')
-rw-r--r-- | server/lib/auth.ts | 40 |
1 files changed, 22 insertions, 18 deletions
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 | |||
126 | authOptions.authName, pluginAuth.npmName, loginOptions.id, authOptions.getWeight() | 126 | authOptions.authName, pluginAuth.npmName, loginOptions.id, authOptions.getWeight() |
127 | ) | 127 | ) |
128 | 128 | ||
129 | const loginResult = await authOptions.login(loginOptions) | 129 | try { |
130 | if (loginResult) { | 130 | const loginResult = await authOptions.login(loginOptions) |
131 | logger.info( | 131 | if (loginResult) { |
132 | 'Login success with auth method %s of plugin %s for %s.', | 132 | logger.info( |
133 | authOptions.authName, pluginAuth.npmName, loginOptions.id | 133 | 'Login success with auth method %s of plugin %s for %s.', |
134 | ) | 134 | authOptions.authName, pluginAuth.npmName, loginOptions.id |
135 | 135 | ) | |
136 | res.locals.bypassLogin = { | 136 | |
137 | bypass: true, | 137 | res.locals.bypassLogin = { |
138 | pluginName: pluginAuth.npmName, | 138 | bypass: true, |
139 | authName: authOptions.authName, | 139 | pluginName: pluginAuth.npmName, |
140 | user: { | 140 | authName: authOptions.authName, |
141 | username: loginResult.username, | 141 | user: { |
142 | email: loginResult.email, | 142 | username: loginResult.username, |
143 | role: loginResult.role || UserRole.USER, | 143 | email: loginResult.email, |
144 | displayName: loginResult.displayName || loginResult.username | 144 | role: loginResult.role || UserRole.USER, |
145 | displayName: loginResult.displayName || loginResult.username | ||
146 | } | ||
145 | } | 147 | } |
146 | } | ||
147 | 148 | ||
148 | return | 149 | return |
150 | } | ||
151 | } catch (err) { | ||
152 | logger.error('Error in auth method %s of plugin %s', authOptions.authName, pluginAuth.npmName, { err }) | ||
149 | } | 153 | } |
150 | } | 154 | } |
151 | } | 155 | } |