aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/oauth-model.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-30 09:42:30 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commite9b0fa5c16ca196a3ba3267af4008782a3e86875 (patch)
treebe54b0abd415f6fb4d0a8f981eedc592d95a7044 /server/lib/oauth-model.ts
parenta5896799f169d3313b63165fe6a79d4149fa6df1 (diff)
downloadPeerTube-e9b0fa5c16ca196a3ba3267af4008782a3e86875.tar.gz
PeerTube-e9b0fa5c16ca196a3ba3267af4008782a3e86875.tar.zst
PeerTube-e9b0fa5c16ca196a3ba3267af4008782a3e86875.zip
Auth plugin compat with regular user accounts
Diffstat (limited to 'server/lib/oauth-model.ts')
-rw-r--r--server/lib/oauth-model.ts12
1 files changed, 8 insertions, 4 deletions
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts
index 8d8a6d85e..136abd0c4 100644
--- a/server/lib/oauth-model.ts
+++ b/server/lib/oauth-model.ts
@@ -109,10 +109,14 @@ async function getUser (usernameOrEmail?: string, password?: string) {
109 let user = await UserModel.loadByEmail(obj.user.email) 109 let user = await UserModel.loadByEmail(obj.user.email)
110 if (!user) user = await createUserFromExternal(obj.pluginName, obj.user) 110 if (!user) user = await createUserFromExternal(obj.pluginName, obj.user)
111 111
112 // This user does not belong to this plugin, skip it 112 // If the user does not belongs to a plugin, it was created before its installation
113 if (user.pluginAuth !== obj.pluginName) return null 113 // Then we just go through a regular login process
114 if (user.pluginAuth !== null) {
115 // This user does not belong to this plugin, skip it
116 if (user.pluginAuth !== obj.pluginName) return null
114 117
115 return user 118 return user
119 }
116 } 120 }
117 121
118 logger.debug('Getting User (username/email: ' + usernameOrEmail + ', password: ******).') 122 logger.debug('Getting User (username/email: ' + usernameOrEmail + ', password: ******).')
@@ -122,7 +126,7 @@ async function getUser (usernameOrEmail?: string, password?: string) {
122 if (!user || user.pluginAuth !== null) return null 126 if (!user || user.pluginAuth !== null) return null
123 127
124 const passwordMatch = await user.isPasswordMatch(password) 128 const passwordMatch = await user.isPasswordMatch(password)
125 if (passwordMatch === false) return null 129 if (passwordMatch !== true) return null
126 130
127 if (user.blocked) throw new AccessDeniedError('User is blocked.') 131 if (user.blocked) throw new AccessDeniedError('User is blocked.')
128 132