mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 11:47:28 +01:00
Add disconnect GitHub button
This commit is contained in:
parent
a2125acddd
commit
3d9fe80177
@ -129,8 +129,7 @@ def profile_edit(username):
|
|||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
if not user.can_see_edit_profile(current_user):
|
if not user.can_see_edit_profile(current_user):
|
||||||
flash(gettext("Permission denied"), "danger")
|
abort(403)
|
||||||
return redirect(url_for("users.profile", username=username))
|
|
||||||
|
|
||||||
form = UserProfileForm(obj=user)
|
form = UserProfileForm(obj=user)
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
@ -243,9 +242,31 @@ def account(username):
|
|||||||
if not user:
|
if not user:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
if not user.can_see_edit_profile(current_user):
|
||||||
|
abort(403)
|
||||||
|
|
||||||
return render_template("users/account.html", user=user, tabs=get_setting_tabs(user), current_tab="account")
|
return render_template("users/account.html", user=user, tabs=get_setting_tabs(user), current_tab="account")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/users/<username>/settings/account/disconnect-github/", methods=["POST"])
|
||||||
|
def disconnect_github(username: str):
|
||||||
|
user: User = User.query.filter_by(username=username).one_or_404()
|
||||||
|
|
||||||
|
if not user.can_see_edit_profile(current_user):
|
||||||
|
abort(403)
|
||||||
|
|
||||||
|
if user.password and user.email:
|
||||||
|
user.github_user_id = None
|
||||||
|
user.github_username = None
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
flash(gettext("Removed GitHub account"), "success")
|
||||||
|
else:
|
||||||
|
flash(gettext("You need to add an email address and password before you can remove your GitHub account"), "danger")
|
||||||
|
|
||||||
|
return redirect(url_for("users.account", username=username))
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/users/<username>/delete/", methods=["GET", "POST"])
|
@bp.route("/users/<username>/delete/", methods=["GET", "POST"])
|
||||||
@rank_required(UserRank.ADMIN)
|
@rank_required(UserRank.ADMIN)
|
||||||
def delete(username):
|
def delete(username):
|
||||||
|
@ -30,14 +30,14 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h3>{{ _("Linked Accounts") }}</h3>
|
<h3 class="mt-5">{{ _("Linked Accounts") }}</h3>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Forums</td>
|
<td>Forums</td>
|
||||||
<td>
|
<td>
|
||||||
{% if user.forums_username %}
|
{% if user.forums_username %}
|
||||||
<a class="btn btn-secondary" href="https://forum.minetest.net/memberlist.php?mode=viewprofile&un={{ user.forums_username }}">
|
<a href="https://forum.minetest.net/memberlist.php?mode=viewprofile&un={{ user.forums_username }}">
|
||||||
{{ _("Connected") }} [{{ user.forums_username }}]
|
{{ user.forums_username }}
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ _("Please PM %(rubenwardy)s on the forums to link your account.", rubenwardy=self.ruben_link()) }}
|
{{ _("Please PM %(rubenwardy)s on the forums to link your account.", rubenwardy=self.ruben_link()) }}
|
||||||
@ -48,15 +48,23 @@
|
|||||||
<td>GitHub</td>
|
<td>GitHub</td>
|
||||||
<td>
|
<td>
|
||||||
{% if user.github_username %}
|
{% if user.github_username %}
|
||||||
<a class="btn btn-secondary" href="https://github.com/{{ user.github_username }}">
|
<p>
|
||||||
{{ _("Connected") }} [{{ user.github_username }}]
|
<a href="https://github.com/{{ user.github_username }}">
|
||||||
</a>
|
{{ user.github_username }}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
{% if user == current_user %}
|
{% if user == current_user %}
|
||||||
<a class="btn btn-secondary ms-2" href="{{ url_for('github.view_permissions') }}">
|
<a class="btn btn-secondary" href="{{ url_for('github.view_permissions') }}">
|
||||||
{{ _("View ContentDB's GitHub Permissions") }}
|
{{ _("View ContentDB's GitHub Permissions") }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if user.forums_username %}
|
||||||
|
<form method="post" action="{{ url_for('users.disconnect_github', username=user.username) }}" class="d-inline-block">
|
||||||
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||||
|
<input type="submit" class="btn btn-secondary" value="{{ _('Disconnect') }}" />
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
{% elif user == current_user %}
|
{% elif user == current_user %}
|
||||||
<a class="btn btn-secondary" href="{{ url_for('github.start') }}">
|
<a class="btn btn-secondary" href="{{ url_for('github.start') }}">
|
||||||
{{ _("Link Github") }}
|
{{ _("Link Github") }}
|
||||||
@ -68,18 +76,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% if current_user.rank.at_least(current_user.rank.MODERATOR) %}
|
|
||||||
<a class="btn btn-secondary float-end" href="{{ url_for('admin.audit', username=user.username) }}">
|
|
||||||
{{ _("View All") }}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<h3>{{ _("Recent Account Actions") }}</h3>
|
<h3 class="mt-5">{{ _("Account Deletion and Deactivation") }}</h3>
|
||||||
|
|
||||||
{% from "macros/audit_log.html" import render_audit_log %}
|
|
||||||
{{ render_audit_log(user.audit_log_entries.limit(10).all(), current_user) }}
|
|
||||||
|
|
||||||
<h3>{{ _("Account Deletion and Deactivation") }}</h3>
|
|
||||||
|
|
||||||
{% if current_user.rank.at_least(current_user.rank.ADMIN) %}
|
{% if current_user.rank.at_least(current_user.rank.ADMIN) %}
|
||||||
<a class="btn btn-danger" href="{{ url_for('users.delete', username=user.username) }}">
|
<a class="btn btn-danger" href="{{ url_for('users.delete', username=user.username) }}">
|
||||||
@ -91,4 +89,17 @@
|
|||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
<h3 class="mt-5">{{ _("Recent Account Actions") }}</h3>
|
||||||
|
|
||||||
|
{% from "macros/audit_log.html" import render_audit_log %}
|
||||||
|
{{ render_audit_log(user.audit_log_entries.limit(10).all(), current_user) }}
|
||||||
|
{% if current_user.rank.at_least(current_user.rank.MODERATOR) %}
|
||||||
|
<p class="mt-4">
|
||||||
|
<a class="btn btn-secondary" href="{{ url_for('admin.audit', username=user.username) }}">
|
||||||
|
{{ _("View All") }}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user