Initial Commit
This commit is contained in:
23
api/app/helpers/authentication.py
Normal file
23
api/app/helpers/authentication.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from flask_httpauth import HTTPBasicAuth
|
||||
|
||||
auth = HTTPBasicAuth()
|
||||
|
||||
|
||||
@auth.verify_password
|
||||
def verify_password(username_or_token, password):
|
||||
|
||||
if username_or_token == "user" and password == "passwd":
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def post_login_required(func):
|
||||
def post_decorator(*args, **kwargs):
|
||||
print("post_decorator ", func, *args, **kwargs)
|
||||
return auth.login_required(func)(*args, **kwargs)
|
||||
|
||||
if func.__name__ in ("post", "patch", "delete"):
|
||||
return post_decorator
|
||||
|
||||
return func
|
||||
Reference in New Issue
Block a user