Debug: Add button in admin panel to login to other accounts (#437)

This commit is contained in:
justcool393 2023-01-08 01:16:02 -08:00 committed by GitHub
parent ec4eafdbfc
commit 0ea72e3778
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 3 deletions

20
files/routes/dev.py Normal file
View file

@ -0,0 +1,20 @@
from secrets import token_hex
from flask import session, redirect, request
from files.helpers.const import PERMS
from files.helpers.get import get_user
from files.helpers.wrappers import admin_level_required
from files.__main__ import app
if not app.debug:
raise ImportError("Importing dev routes is not allowed outside of debug mode!")
@app.post('/dev/sessions/')
@admin_level_required(PERMS['DEBUG_LOGIN_TO_OTHERS'])
def login_to_other_account(v):
u = get_user(request.values.get('username'))
session.permanent = True
session["lo_user"] = u.id
session["login_nonce"] = u.login_nonce
session["session_id"] = token_hex(49)
return redirect('/')