Add Google SSO
This pull request adds Google SSO support. There are two main changes: 1. Add the Google auth view resource 2. Make passwords optional when creating a new user. This allows an admin to create a user without a password so that they can only login via Google.
This commit is contained in:
@ -52,7 +52,10 @@ class User(db.Model):
|
||||
:param password:
|
||||
:return:
|
||||
"""
|
||||
return bcrypt.check_password_hash(self.password, password)
|
||||
if self.password:
|
||||
return bcrypt.check_password_hash(self.password, password)
|
||||
else:
|
||||
return False
|
||||
|
||||
def hash_password(self):
|
||||
"""
|
||||
@ -60,8 +63,11 @@ class User(db.Model):
|
||||
|
||||
:return:
|
||||
"""
|
||||
self.password = bcrypt.generate_password_hash(self.password)
|
||||
return self.password
|
||||
if self.password:
|
||||
self.password = bcrypt.generate_password_hash(self.password)
|
||||
return self.password
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
def is_admin(self):
|
||||
|
@ -157,7 +157,7 @@ class UsersList(AuthenticatedResource):
|
||||
"""
|
||||
self.reqparse.add_argument('username', type=str, location='json', required=True)
|
||||
self.reqparse.add_argument('email', type=str, location='json', required=True)
|
||||
self.reqparse.add_argument('password', type=str, location='json', required=True)
|
||||
self.reqparse.add_argument('password', type=str, location='json', default=None)
|
||||
self.reqparse.add_argument('active', type=bool, default=True, location='json')
|
||||
self.reqparse.add_argument('roles', type=roles, default=[], location='json')
|
||||
|
||||
|
Reference in New Issue
Block a user