Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
The meaning of life
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Monty Pythons the Meaning of Life
The meaning of life
Commits
99218977
Commit
99218977
authored
2 years ago
by
Stefan Otayagich
Browse files
Options
Downloads
Patches
Plain Diff
some bad possible fixes for google login in cosmos
parent
b95b5f0c
No related branches found
No related tags found
1 merge request
!66
some bad possible fixes for google login in cosmos
Pipeline
#15729
passed
2 years ago
Stage: build
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tjts5901/authentication/utils.py
+6
-1
6 additions, 1 deletion
src/tjts5901/authentication/utils.py
src/tjts5901/user/models.py
+5
-5
5 additions, 5 deletions
src/tjts5901/user/models.py
with
11 additions
and
6 deletions
src/tjts5901/authentication/utils.py
+
6
−
1
View file @
99218977
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
src/tjts5901/user/models.py
+
5
−
5
View file @
99218977
...
...
@@ -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
=
Tru
e
)
name
=
StringField
(
required
=
True
,
unique
=
Fals
e
)
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment