]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/oauth-model.ts
Check banned status for external auths
[github/Chocobozzz/PeerTube.git] / server / lib / oauth-model.ts
index f7ea98b4174cee8854dd827e55319a8b19daff36..3f8b8e6183e645354607125bc7517a9e86e4ebc2 100644 (file)
@@ -119,6 +119,8 @@ async function getUser (usernameOrEmail?: string, password?: string) {
       // This user does not belong to this plugin, skip it
       if (user.pluginAuth !== obj.pluginName) return null
 
+      checkUserValidityOrThrow(user)
+
       return user
     }
   }
@@ -132,7 +134,7 @@ async function getUser (usernameOrEmail?: string, password?: string) {
   const passwordMatch = await user.isPasswordMatch(password)
   if (passwordMatch !== true) return null
 
-  if (user.blocked) throw new AccessDeniedError('User is blocked.')
+  checkUserValidityOrThrow(user)
 
   if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION && user.emailVerified === false) {
     throw new AccessDeniedError('User email is not verified.')
@@ -238,3 +240,7 @@ async function createUserFromExternal (pluginAuth: string, options: {
 
   return user
 }
+
+function checkUserValidityOrThrow (user: MUser) {
+  if (user.blocked) throw new AccessDeniedError('User is blocked.')
+}