Improve the access logging
This commit is contained in:
parent
2443046b62
commit
2e44c2b0b1
@ -53,15 +53,20 @@ class validation():
|
||||
cursor.close()
|
||||
db_main.close()
|
||||
|
||||
loggorilla.accss(APIADDR, f"Session ID : {r_session['id' ] if 'id' in r_session else None}" )
|
||||
loggorilla.accss(APIADDR, f"Session Start : {r_session['start' ].strftime('%Y-%m-%d %H:%M:%S') if 'start' in r_session else None}" )
|
||||
loggorilla.accss(APIADDR, f"Session End : {r_session['end' ].strftime('%Y-%m-%d %H:%M:%S') if 'end' in r_session else None}" )
|
||||
loggorilla.accss(APIADDR, f"Profile ID : {r_profile['id' ] if 'id' in r_profile else None}" )
|
||||
loggorilla.accss(APIADDR, f"Profile Username : {r_profile['username' ] if 'username' in r_profile else None}" )
|
||||
loggorilla.accss(APIADDR, f"Profile Email : {r_profile['email' ] if 'email' in r_profile else None}" )
|
||||
loggorilla.accss(APIADDR, f"Profile Phone : {r_profile['phone' ] if 'phone' in r_profile else None}" )
|
||||
|
||||
loggorilla.prcss(APIADDR, "Validation")
|
||||
if 0 not in r_profile['roles'] and datetime.datetime.now() > r_session['end']:
|
||||
loggorilla.accss(APIADDR, "Expired. Your session removed." )
|
||||
loggorilla.prcss(APIADDR, "Deleting")
|
||||
self.cursor.execute("DELETE FROM auth_session WHERE id = %s ; ", (r_session['id'],) )
|
||||
loggorilla.prcss(APIADDR, "Giving response")
|
||||
loggorilla.accss(APIADDR, "Expired. Your session removed." )
|
||||
loggorilla.accss(APIADDR, f"Session: {r_session}" )
|
||||
loggorilla.accss(APIADDR, f"Session ID: {r_session['id']}" )
|
||||
loggorilla.accss(APIADDR, f"Profile: {r_profile}" )
|
||||
response["status" ] = "failed"
|
||||
response["desc" ] = "Expired. Your session removed."
|
||||
response["data" ] = {
|
||||
@ -74,11 +79,8 @@ class validation():
|
||||
}
|
||||
redirect('/logout?msg=expired')
|
||||
elif 0 not in r_profile['roles'] and r_profile["count"] == 0:
|
||||
loggorilla.prcss(APIADDR, "Giving response")
|
||||
loggorilla.accss(APIADDR, "No active account for this" )
|
||||
loggorilla.accss(APIADDR, f"Session: {r_session}" )
|
||||
loggorilla.accss(APIADDR, f"Session ID: {r_session['id']}" )
|
||||
loggorilla.accss(APIADDR, f"Profile: {r_profile}" )
|
||||
loggorilla.prcss(APIADDR, "Giving response")
|
||||
response["status" ] = "failed"
|
||||
response["desc" ] = "No active account for this"
|
||||
response["data" ] = {
|
||||
@ -92,8 +94,8 @@ class validation():
|
||||
}
|
||||
abort(403, "Please contact us if you still had a problem.") # 403 Forbidden
|
||||
elif any(role in allowed_roles for role in r_profile['roles']):
|
||||
loggorilla.prcss(APIADDR, "Giving response")
|
||||
loggorilla.accss(APIADDR, "User roles authorized" )
|
||||
loggorilla.prcss(APIADDR, "Giving response")
|
||||
response["status" ] = "success"
|
||||
response["desc" ] = "User roles authorized"
|
||||
response["data" ] = {
|
||||
@ -106,15 +108,8 @@ class validation():
|
||||
}
|
||||
return response
|
||||
else:
|
||||
loggorilla.prcss(APIADDR, "Giving response")
|
||||
loggorilla.accss(APIADDR, "User roles unauthorized" )
|
||||
loggorilla.accss(APIADDR, f"Session ID : {r_session['id']}" )
|
||||
loggorilla.accss(APIADDR, f"Session Start : {r_session['start'].strftime('%Y-%m-%d %H:%M:%S')}" )
|
||||
loggorilla.accss(APIADDR, f"Session End : {r_session['end'].strftime('%Y-%m-%d %H:%M:%S')}" )
|
||||
loggorilla.accss(APIADDR, f"Profile ID : {r_profile['id']}" )
|
||||
loggorilla.accss(APIADDR, f"Profile Username : {r_profile['username']}" )
|
||||
loggorilla.accss(APIADDR, f"Profile Email : {r_profile['email']}" )
|
||||
loggorilla.accss(APIADDR, f"Profile Phone : {r_profile['phone']}" )
|
||||
loggorilla.prcss(APIADDR, "Giving response")
|
||||
response["status" ] = "failed"
|
||||
response["desc" ] = "User roles unauthorized"
|
||||
response["data" ] = {
|
||||
|
Loading…
Reference in New Issue
Block a user