Skip to content
Snippets Groups Projects
Commit 99218977 authored by Stefan Otayagich's avatar Stefan Otayagich
Browse files

some bad possible fixes for google login in cosmos

parent b95b5f0c
No related branches found
No related tags found
1 merge request!66some bad possible fixes for google login in cosmos
Pipeline #15729 passed
......@@ -4,7 +4,7 @@ Helper functions to help with authentication
import json
from typing import Union
from flask import abort, session
from flask import abort, flash, redirect, session, url_for
from google.oauth2 import id_token
from google.auth.transport import requests
from mongoengine.errors import DoesNotExist, MultipleObjectsReturned
......@@ -78,6 +78,11 @@ def google_login(token: str):
except MultipleObjectsReturned:
# should not get here...
abort(400)
except Exception:
# should not get here... but some cosmosDB indexing stuff..
# Quick fix
flash("Something went wrong..", 'error')
return redirect(url_for('authentication_blueprint.login'))
return create_token_for_user(user)
......
......@@ -30,14 +30,14 @@ class User(Document):
is stored in the 'google' field. This way it is easy to create new users with
google information and link existing users to their google accounts.
"""
name = StringField(required=True, unique=True)
name = StringField(required=True, unique=False)
email = EmailField(required=True, unique=True)
# is not required as other authentication methods are available.
password = StringField(min_length=MIN_PASSWORD_LENGTH)
role = StringField(required=True, default=USER_ROLE, choises=ROLES)
timezone = StringField(default="UTC") # Choises
currency = StringField(default="eur") # Choises
locale = StringField(default="en") # Choises
timezone = StringField(default="UTC") # TODO Choises
currency = StringField(default="eur") # TODO Choises
locale = StringField(default="en") # TODO Choises
google = EmbeddedDocumentField(GoogleAccount, default=None, sparse=True)
@classmethod
......@@ -59,4 +59,4 @@ class User(Document):
try:
return cls.objects.get(email=email)
except:
return None
\ No newline at end of file
return None
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment