use kwargs for parse_repository_name
This commit is contained in:
parent
3b52a255b2
commit
bb46cc933d
15 changed files with 285 additions and 270 deletions
|
@ -3,18 +3,18 @@ import requests
|
|||
|
||||
from flask import request, redirect, url_for, Blueprint
|
||||
from flask.ext.login import current_user
|
||||
|
||||
from endpoints.common import common_login, route_show_if, parse_repository_name
|
||||
from endpoints.web import render_page_template_with_routedata
|
||||
from app import app, analytics, get_app_url, github_login, google_login, dex_login
|
||||
from data import model
|
||||
from util.validation import generate_valid_usernames
|
||||
from util.http import abort
|
||||
from auth.auth import require_session_login
|
||||
from peewee import IntegrityError
|
||||
|
||||
import features
|
||||
|
||||
from app import app, analytics, get_app_url, github_login, google_login, dex_login
|
||||
from auth.auth import require_session_login
|
||||
from data import model
|
||||
from endpoints.common import common_login, route_show_if
|
||||
from endpoints.web import render_page_template_with_routedata
|
||||
from util.security.strictjwt import decode, InvalidTokenError
|
||||
from util.validation import generate_valid_usernames
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
client = app.config['HTTPCLIENT']
|
||||
|
@ -24,10 +24,10 @@ def render_ologin_error(service_name,
|
|||
error_message='Could not load user data. The token may have expired.'):
|
||||
user_creation = features.USER_CREATION and features.DIRECT_LOGIN
|
||||
return render_page_template_with_routedata('ologinerror.html',
|
||||
service_name=service_name,
|
||||
error_message=error_message,
|
||||
service_url=get_app_url(),
|
||||
user_creation=user_creation)
|
||||
service_name=service_name,
|
||||
error_message=error_message,
|
||||
service_url=get_app_url(),
|
||||
user_creation=user_creation)
|
||||
|
||||
|
||||
def get_user(service, token):
|
||||
|
@ -150,7 +150,7 @@ def github_oauth_callback():
|
|||
# Retrieve the user's orgnizations (if organization filtering is turned on)
|
||||
if github_login.allowed_organizations() is not None:
|
||||
get_orgs = client.get(github_login.orgs_endpoint(), params=token_param,
|
||||
headers={'Accept': 'application/vnd.github.moondragon+json'})
|
||||
headers={'Accept': 'application/vnd.github.moondragon+json'})
|
||||
|
||||
organizations = set([org.get('login').lower() for org in get_orgs.json()])
|
||||
if not (organizations & set(github_login.allowed_organizations())):
|
||||
|
@ -271,8 +271,10 @@ def dex_oauth_callback():
|
|||
payload = decode_user_jwt(token, dex_login)
|
||||
except InvalidTokenError:
|
||||
logger.exception('Exception when decoding returned JWT')
|
||||
return render_ologin_error(dex_login.public_title,
|
||||
'Could not decode response. Please contact your system administrator about this error.')
|
||||
return render_ologin_error(
|
||||
dex_login.public_title,
|
||||
'Could not decode response. Please contact your system administrator about this error.',
|
||||
)
|
||||
|
||||
username = get_email_username(payload)
|
||||
metadata = {}
|
||||
|
@ -281,9 +283,11 @@ def dex_oauth_callback():
|
|||
email_address = payload['email']
|
||||
|
||||
if not payload.get('email_verified', False):
|
||||
return render_ologin_error(dex_login.public_title,
|
||||
return render_ologin_error(
|
||||
dex_login.public_title,
|
||||
'A verified e-mail address is required for login. Please verify your ' +
|
||||
'e-mail address in %s and try again.' % dex_login.public_title)
|
||||
'e-mail address in %s and try again.' % dex_login.public_title,
|
||||
)
|
||||
|
||||
|
||||
return conduct_oauth_login(dex_login, dex_id, username, email_address,
|
||||
|
@ -304,8 +308,10 @@ def dex_oauth_attach():
|
|||
payload = decode_user_jwt(token, dex_login)
|
||||
except jwt.InvalidTokenError:
|
||||
logger.exception('Exception when decoding returned JWT')
|
||||
return render_ologin_error(dex_login.public_title,
|
||||
'Could not decode response. Please contact your system administrator about this error.')
|
||||
return render_ologin_error(
|
||||
dex_login.public_title,
|
||||
'Could not decode response. Please contact your system administrator about this error.',
|
||||
)
|
||||
|
||||
user_obj = current_user.db_user()
|
||||
dex_id = payload['sub']
|
||||
|
@ -315,7 +321,7 @@ def dex_oauth_attach():
|
|||
model.user.attach_federated_login(user_obj, 'dex', dex_id, metadata=metadata)
|
||||
except IntegrityError:
|
||||
err = '%s account is already attached to a %s account' % (dex_login.public_title,
|
||||
app.config['REGISTRY_TITLE_SHORT'])
|
||||
app.config['REGISTRY_TITLE_SHORT'])
|
||||
return render_ologin_error(dex_login.public_title, err)
|
||||
|
||||
return redirect(url_for('web.user'))
|
||||
|
|
Reference in a new issue