Error when login with rest api [solved]

Hi.

When i login and the usr and pwd are correct (the user exist and the password is correct) i can login and everything is ok. But when i login and usr or pwd is not correct i get the following error:

jenv.globals.update(get_allowed_functions_for_jenv())
File "/Users/saguas/erpnext4/erpnext/frappe_v5/frappe-bench/apps/frappe/frappe/utils/jinja.py", line 71, in get_allowed_functions_for_jenv
"user": hasattr(frappe.local, "session") and frappe.local.session.user or "Guest",
AttributeError: 'NoneType' object has no attribute 'user'

I check the error and hasattr(frappe.local, “session”) return true but frappe.local.session is None.

When i login with ajax call everything is ok with or without correct user or password.

Is this a bug?

Thanks.

Seems like a bug. It should throw AuthenticationError can you fix it and send a pull-request?

Hi @rmehta.

Yesterday i try all day to solve this problem. I was thinking what i am doing wrong!

But when i wake up this morning i have a moment of inspiration and find out what was the problem. And the problem was because when i did the rest api request i forgot to set in the headers Accept application/json.
This solve my problem.
Sorry to bother you.

1 Like