Verified Commit 4dc04b18 authored by Peter Stanko's avatar Peter Stanko
Browse files

Fixes in the gitlab 5

parent 68fd5887
Pipeline #28601 passed with stage
in 13 minutes and 29 seconds
......@@ -4,7 +4,7 @@ from flask import Flask, Response, make_response, redirect, request, session
from flask_oauthlib.client import OAuthRemoteApp
from flask_restplus import Namespace
from gitlab import Gitlab
from gitlab.v4.objects import User
from gitlab.v4.objects import User, CurrentUser
from portal import gitlab_factory, logger, oauth
from portal.rest import rest_api
......@@ -15,16 +15,6 @@ log = logger.get_logger(__name__)
oauth_namespace = Namespace('oauth')
def extract_user_info(me: User) -> dict:
log.debug(f"[GITLAB] Received info: {me}")
return dict(
uco=None,
name=me.name,
username=me.username,
email=me.email
)
def gitlab_enabled(app: Flask) -> bool:
return app.config.get('GITLAB_URL') and \
app.config.get('GITLAB_CLIENT_ID') and \
......@@ -101,7 +91,7 @@ def user_oauth_register(user_info):
return new_user
def user_login(user_info) -> Response:
def user_login(user_info: CurrentUser) -> Response:
from portal.service.rest import RestService
rest = RestService()
user = rest.find.user(user_info.username, throws=False)
......@@ -134,8 +124,7 @@ def login_to_gitlab_with_token(token):
log.debug(f"Logging in to gitlab with token: {token}")
try:
me = gitlab_get_user(token)
user_info = extract_user_info(me)
login = user_login(user_info)
login = user_login(me)
login.set_cookie('gitlab_token', token)
return login
except Exception as ex:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment