Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Portal API Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Kontr 2.0
Portal API Backend
Commits
5e1a8a3c
There was an error fetching the commit references. Please try again later.
Commit
5e1a8a3c
authored
7 years ago
by
Barbora Kompišová
Browse files
Options
Downloads
Patches
Plain Diff
oauth model + logic fixes
parent
fb5ae3ff
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
portal/database/models.py
+1
-1
1 addition, 1 deletion
portal/database/models.py
portal/rest/auth/gitlab.py
+3
-1
3 additions, 1 deletion
portal/rest/auth/gitlab.py
with
4 additions
and
2 deletions
portal/database/models.py
+
1
−
1
View file @
5e1a8a3c
...
@@ -31,7 +31,7 @@ def _repr(instance):
...
@@ -31,7 +31,7 @@ def _repr(instance):
class
User
(
db
.
Model
,
EntityBase
):
class
User
(
db
.
Model
,
EntityBase
):
__tablename__
=
'
user
'
__tablename__
=
'
user
'
id
=
db
.
Column
(
db
.
Text
(
length
=
36
),
default
=
lambda
:
str
(
uuid
.
uuid4
()),
primary_key
=
True
)
id
=
db
.
Column
(
db
.
Text
(
length
=
36
),
default
=
lambda
:
str
(
uuid
.
uuid4
()),
primary_key
=
True
)
uco
=
db
.
Column
(
db
.
Integer
,
unique
=
True
,
nullable
=
False
)
uco
=
db
.
Column
(
db
.
Integer
,
unique
=
True
)
email
=
db
.
Column
(
db
.
String
(
50
),
unique
=
True
,
nullable
=
False
)
email
=
db
.
Column
(
db
.
String
(
50
),
unique
=
True
,
nullable
=
False
)
username
=
db
.
Column
(
db
.
String
(
15
),
unique
=
True
,
nullable
=
False
)
username
=
db
.
Column
(
db
.
String
(
15
),
unique
=
True
,
nullable
=
False
)
name
=
db
.
Column
(
db
.
String
(
50
))
name
=
db
.
Column
(
db
.
String
(
50
))
...
...
This diff is collapsed.
Click to expand it.
portal/rest/auth/gitlab.py
+
3
−
1
View file @
5e1a8a3c
...
@@ -44,6 +44,7 @@ oauth_blueprint = Blueprint('oauth', __name__, url_prefix='/oauth')
...
@@ -44,6 +44,7 @@ oauth_blueprint = Blueprint('oauth', __name__, url_prefix='/oauth')
@oauth_blueprint.route
(
'
/login
'
,
methods
=
[
'
GET
'
])
@oauth_blueprint.route
(
'
/login
'
,
methods
=
[
'
GET
'
])
def
oauth_login
():
def
oauth_login
():
callback
=
url_for
(
'
oauth.oauth_authorized
'
,
_external
=
True
,
_scheme
=
'
https
'
)
callback
=
url_for
(
'
oauth.oauth_authorized
'
,
_external
=
True
,
_scheme
=
'
https
'
)
log
.
debug
(
f
"
Callback set:
{
callback
}
"
)
return
gitlab
.
authorize
(
callback
=
callback
)
return
gitlab
.
authorize
(
callback
=
callback
)
...
@@ -57,12 +58,13 @@ def user_oauth_register(user_info):
...
@@ -57,12 +58,13 @@ def user_oauth_register(user_info):
new_user
.
name
=
user_info
[
'
name
'
]
new_user
.
name
=
user_info
[
'
name
'
]
service
.
write_entity
(
new_user
)
service
.
write_entity
(
new_user
)
log
.
debug
(
f
"
Created user=
{
new_user
}
"
)
log
.
debug
(
f
"
Created user=
{
new_user
}
"
)
return
new_user
def
user_login
(
user_info
):
def
user_login
(
user_info
):
user
=
find_user
(
user_info
[
'
username
'
])
user
=
find_user
(
user_info
[
'
username
'
])
if
not
user
:
if
not
user
:
user_oauth_register
(
user_info
)
user
=
user_oauth_register
(
user_info
)
resp
=
make_response
(
redirect
(
oauth
.
app
.
config
.
get
(
'
FRONTEND_URL
'
)))
resp
=
make_response
(
redirect
(
oauth
.
app
.
config
.
get
(
'
FRONTEND_URL
'
)))
resp
.
set_cookie
(
'
username
'
,
user
.
username
)
resp
.
set_cookie
(
'
username
'
,
user
.
username
)
return
resp
return
resp
...
...
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