mirror of https://git.sr.ht/~sircmpwn/hub.sr.ht
15 lines
457 B
Python
15 lines
457 B
Python
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
|