make "unban user" button in userpage work instantly

master
Aevann1 2022-11-05 04:07:29 +02:00
parent 5ef2b41d5e
commit ab9c0288fb
2 changed files with 14 additions and 21 deletions

View File

@ -1062,8 +1062,7 @@ def unban_user(user_id, v):
) )
g.db.add(ma) g.db.add(ma)
if "@" in request.referrer: return redirect(user.url) return {"message": f"@{user.username} has been unbanned!"}
else: return {"message": f"@{user.username} has been unbanned!"}
@app.post("/mute_user/<int:user_id>/<int:mute_status>") @app.post("/mute_user/<int:user_id>/<int:mute_status>")
@limiter.limit("1/second;30/minute;200/hour;1000/day") @limiter.limit("1/second;30/minute;200/hour;1000/day")

View File

@ -42,25 +42,19 @@
</div> </div>
{% endif %} {% endif %}
{% if v.admin_level >= PERMS['USER_BAN'] %} {% if v.admin_level >= PERMS['USER_BAN'] %}
{% if u.is_suspended %} <button type="button" id="unban-{{deviceType}}" class="mt-1 mb-3 {% if not u.is_suspended %}d-none{% endif %} btn btn-success" onclick="postToastSwitch(this,'/unban_user/{{u.id}}','ban-{{deviceType}}','unban-{{deviceType}}','d-none')">Unban user</button>
<form class="mb-2" action="/unban_user/{{u.id}}" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}"> <form id="ban-{{deviceType}}" class="mb-3 {% if u.is_suspended %}d-none{% endif %}" action="/ban_user/{{u.id}}" method="post">
<input type="hidden" name="redir" value="true"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<input type="submit" onclick="disable(this)" class="btn btn-success" value="Unban user"> <input type="hidden" name="redir" value="true">
</form> <input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Ban Reason" oninput="document.getElementById('user-ban-submit-{{deviceType}}').disabled=false" required>
{% else %} <input autocomplete="off" style="font-size:11px" type="number" step="any" class="form-control" name="days" placeholder="Days (blank = permanent)">
<form class="mb-2" action="/ban_user/{{u.id}}" method="post"> <div class="custom-control custom-checkbox mb-1">
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input autocomplete="off" type="checkbox" id="alts-2-{{deviceType}}" class="custom-control-input" name="alts" value="1">
<input type="hidden" name="redir" value="true"> <label class="custom-control-label" for="alts-2-{{deviceType}}">Include alts</label>
<input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Ban Reason" oninput="document.getElementById('user-ban-submit-{{deviceType}}').disabled=false" required> </div>
<input autocomplete="off" style="font-size:11px" type="number" step="any" class="form-control" name="days" placeholder="Days (blank = permanent)"> <input autocomplete="off" id="user-ban-submit-{{deviceType}}" type="submit" onclick="disable(this)" class="btn btn-danger" value="Ban user" disabled>
<div class="custom-control custom-checkbox mb-1"> </form>
<input autocomplete="off" type="checkbox" id="alts-2-{{deviceType}}" class="custom-control-input" name="alts" value="1">
<label class="custom-control-label" for="alts-2-{{deviceType}}">Include alts</label>
</div>
<input autocomplete="off" id="user-ban-submit-{{deviceType}}" type="submit" onclick="disable(this)" class="btn btn-danger" value="Ban user" disabled>
</form>
{% endif %}
{% endif %} {% endif %}
{% if v.admin_level >= PERMS['USER_SHADOWBAN'] %} {% if v.admin_level >= PERMS['USER_SHADOWBAN'] %}
{% if u.shadowbanned %} {% if u.shadowbanned %}