Check OAuth name type with fallback
This commit is contained in:
		
							parent
							
								
									21abe43f3b
								
							
						
					
					
						commit
						1ad9be9c07
					
				| 
						 | 
					@ -277,8 +277,13 @@ class OAuthManager:
 | 
				
			||||||
                        picture_url = ""
 | 
					                        picture_url = ""
 | 
				
			||||||
                if not picture_url:
 | 
					                if not picture_url:
 | 
				
			||||||
                    picture_url = "/user.png"
 | 
					                    picture_url = "/user.png"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                username_claim = auth_manager_config.OAUTH_USERNAME_CLAIM
 | 
					                username_claim = auth_manager_config.OAUTH_USERNAME_CLAIM
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                username = user_data.get(username_claim)
 | 
				
			||||||
 | 
					                if not isinstance(username, str):
 | 
				
			||||||
 | 
					                    username = "User"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                role = self.get_user_role(None, user_data)
 | 
					                role = self.get_user_role(None, user_data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                user = Auths.insert_new_auth(
 | 
					                user = Auths.insert_new_auth(
 | 
				
			||||||
| 
						 | 
					@ -286,7 +291,7 @@ class OAuthManager:
 | 
				
			||||||
                    password=get_password_hash(
 | 
					                    password=get_password_hash(
 | 
				
			||||||
                        str(uuid.uuid4())
 | 
					                        str(uuid.uuid4())
 | 
				
			||||||
                    ),  # Random password, not used
 | 
					                    ),  # Random password, not used
 | 
				
			||||||
                    name=user_data.get(username_claim, "User"),
 | 
					                    name=username,
 | 
				
			||||||
                    profile_image_url=picture_url,
 | 
					                    profile_image_url=picture_url,
 | 
				
			||||||
                    role=role,
 | 
					                    role=role,
 | 
				
			||||||
                    oauth_sub=provider_sub,
 | 
					                    oauth_sub=provider_sub,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue