aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-27 10:19:14 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commit055cfb11a9d688dbc2dce5c164d1f0b311918378 (patch)
treec93f008b3e5463a9b8d024b45e5ba4b9f549a76b /server/lib
parente307e4fce39853d445d086f92b8c556c363ee15d (diff)
downloadPeerTube-055cfb11a9d688dbc2dce5c164d1f0b311918378.tar.gz
PeerTube-055cfb11a9d688dbc2dce5c164d1f0b311918378.tar.zst
PeerTube-055cfb11a9d688dbc2dce5c164d1f0b311918378.zip
Add plugin auth migrations
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/auth.ts40
-rw-r--r--server/lib/plugins/register-helpers-store.ts2
2 files changed, 24 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}
diff --git a/server/lib/plugins/register-helpers-store.ts b/server/lib/plugins/register-helpers-store.ts
index 679ed3650..687974ccf 100644
--- a/server/lib/plugins/register-helpers-store.ts
+++ b/server/lib/plugins/register-helpers-store.ts
@@ -198,6 +198,8 @@ export class RegisterHelpersStore {
198 return { 198 return {
199 getSetting: (name: string) => PluginModel.getSetting(this.plugin.name, this.plugin.type, name), 199 getSetting: (name: string) => PluginModel.getSetting(this.plugin.name, this.plugin.type, name),
200 200
201 getSettings: (names: string[]) => PluginModel.getSettings(this.plugin.name, this.plugin.type, names),
202
201 setSetting: (name: string, value: string) => PluginModel.setSetting(this.plugin.name, this.plugin.type, name, value) 203 setSetting: (name: string, value: string) => PluginModel.setSetting(this.plugin.name, this.plugin.type, name, value)
202 } 204 }
203 } 205 }