You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
hub.sr.ht/hubsrht/decorators.py

14 lines
457 B

from flask import redirect, abort, current_app, request
from functools import wraps
from srht.oauth import current_user, UserType
def adminrequired(f):
@wraps(f)
def wrapper(*args, **kwargs):
if not current_user:
return redirect(current_app.oauth_service.oauth_url(request.url))
elif current_user.user_type != UserType.admin:
abort(403)
else:
return f(*args, **kwargs)
return wrapper