mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 20:51:49 +02:00
debug
This commit is contained in:
parent
9bffe72607
commit
3fb25bdd7e
1 changed files with 8 additions and 0 deletions
|
@ -8,6 +8,9 @@ from wtforms.fields.core import BooleanField
|
||||||
from ihatemoney.forms import EditProjectForm, MemberForm, ProjectForm, get_billform_for
|
from ihatemoney.forms import EditProjectForm, MemberForm, ProjectForm, get_billform_for
|
||||||
from ihatemoney.models import Bill, Person, Project, db
|
from ihatemoney.models import Bill, Person, Project, db
|
||||||
|
|
||||||
|
def log(txt):
|
||||||
|
with open("logs", "w+") as f:
|
||||||
|
f.write(txt)
|
||||||
|
|
||||||
def need_auth(f):
|
def need_auth(f):
|
||||||
"""Check the request for basic authentication for a given project.
|
"""Check the request for basic authentication for a given project.
|
||||||
|
@ -23,6 +26,10 @@ def need_auth(f):
|
||||||
# Use Basic Auth
|
# Use Basic Auth
|
||||||
if auth and project_id and auth.username == project_id:
|
if auth and project_id and auth.username == project_id:
|
||||||
project = Project.query.get(auth.username)
|
project = Project.query.get(auth.username)
|
||||||
|
if project:
|
||||||
|
log(project.password + auth.password)
|
||||||
|
else:
|
||||||
|
log("no project")
|
||||||
if project and check_password_hash(project.password, auth.password):
|
if project and check_password_hash(project.password, auth.password):
|
||||||
# The whole project object will be passed instead of project_id
|
# The whole project object will be passed instead of project_id
|
||||||
kwargs.pop("project_id")
|
kwargs.pop("project_id")
|
||||||
|
@ -32,6 +39,7 @@ def need_auth(f):
|
||||||
auth_header = request.headers.get("Authorization", "")
|
auth_header = request.headers.get("Authorization", "")
|
||||||
auth_token = ""
|
auth_token = ""
|
||||||
try:
|
try:
|
||||||
|
log(auth_header)
|
||||||
auth_token = auth_header.split(" ")[1]
|
auth_token = auth_header.split(" ")[1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
abort(401)
|
abort(401)
|
||||||
|
|
Loading…
Reference in a new issue