2
0
mirror of https://github.com/codl/forget synced 2025-01-24 04:32:39 +01:00
forget-cancellare-vecchi-toot/lib/auth.py
2017-08-12 01:04:22 +02:00

21 lines
517 B
Python

from flask import g, redirect, jsonify, make_response
from functools import wraps
def require_auth(fun):
@wraps(fun)
def wrapper(*args, **kwargs):
if not g.viewer:
return redirect('/')
return fun(*args, **kwargs)
return wrapper
def require_auth_api(fun):
@wraps(fun)
def wrapper(*args, **kwargs):
if not g.viewer:
return make_response((jsonify(status='error', error='not logged in'), 403))
return fun(*args, **kwargs)
return wrapper