mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-05 12:47:29 +01:00
Add registering using Github
This commit is contained in:
parent
bb9d589fb5
commit
6be5b3eb42
@ -67,6 +67,10 @@ Sign in
|
|||||||
<aside class="box box_grey">
|
<aside class="box box_grey">
|
||||||
<h2>New here?</h2>
|
<h2>New here?</h2>
|
||||||
|
|
||||||
|
<div class="box box_grey alert alert-error">
|
||||||
|
Please use Github login instead!
|
||||||
|
</div>
|
||||||
|
|
||||||
{% if user_manager.enable_register and not user_manager.require_invitation %}
|
{% if user_manager.enable_register and not user_manager.require_invitation %}
|
||||||
<a href="{{ url_for('github_signin_page') }}">{%trans%}Create an account{%endtrans%}</a>
|
<a href="{{ url_for('github_signin_page') }}">{%trans%}Create an account{%endtrans%}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -24,6 +24,9 @@ def _do_login_user(user, remember_me=False):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
user.active = True
|
user.active = True
|
||||||
|
if not user.rank.atLeast(UserRank.NEW_MEMBER):
|
||||||
|
user.rank = UserRank.NEW_MEMBER
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
# Check if user account has been disabled
|
# Check if user account has been disabled
|
||||||
@ -91,8 +94,16 @@ def github_authorized(oauth_token):
|
|||||||
# If not logged in, log in
|
# If not logged in, log in
|
||||||
else:
|
else:
|
||||||
if userByGithub is None:
|
if userByGithub is None:
|
||||||
flash("Authorization failed [err=gh-no-such-account]", "danger")
|
newUser = User(username)
|
||||||
return redirect(url_for("user.login"))
|
newUser.github_username = username
|
||||||
|
db.session.add(newUser)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
if not _login_user(newUser):
|
||||||
|
raise Exception("Unable to login as user we just created")
|
||||||
|
|
||||||
|
flash("Created an account", "success")
|
||||||
|
return redirect(url_for("user_profile_page", username=username))
|
||||||
elif _login_user(userByGithub):
|
elif _login_user(userByGithub):
|
||||||
return redirect(next_url or url_for("home_page"))
|
return redirect(next_url or url_for("home_page"))
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user