Fix two bugs

This commit is contained in:
rubenwardy 2018-07-30 00:42:11 +01:00
parent dd6257a0a0
commit b296b9b299
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
2 changed files with 6 additions and 3 deletions

View File

@ -36,7 +36,10 @@ class MyModelView(ModelView):
def inaccessible_callback(self, name, **kwargs):
# redirect to login page if user doesn't have access
return redirect(url_for('user.login', next=request.url))
if current_user.is_authenticated:
abort(403)
else:
return redirect(url_for('user.login', next=request.url))
admin = Admin(app, name='ContentDB', template_mode='bootstrap3', url="/admin/db")
admin.add_view(MyModelView(User, db.session))

View File

@ -51,9 +51,9 @@ def github_authorized(oauth_token):
if current_user and current_user.is_authenticated:
if userByGithub is None:
current_user.github_username = username
db.session.add(auth)
db.session.commit()
return redirect(url_for("gitAccount", id=auth.id))
flash("Linked github to account", "success")
return redirect(url_for("home_page"))
else:
flash("Github account is already associated with another user", "danger")
return redirect(url_for("home_page"))