Custom Login Api Method


how can i call / use /api/method/login method in my custom app,
i am trying to make custom login method, which will return special result.

I think this discussion will helpful to you.

Hi Mahesh, I used similar but getting error.

login_manager = LoginManager()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 104, in __init__
if frappe.local.form_dict.get('cmd')=='login' or frappe.local.request.path=="/api/method/login":
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/werkzeug/", line 74, in __getattr__
raise AttributeError(name)
AttributeError: request

my code :

def login_instructor(usr, pwd):
	login_manager = LoginManager()
	if frappe.response['message'] == 'Logged In':
		instructor = frappe.db.get_value("Instructor", {"user": login_manager.user}, "name")
		if instructor: return instructor
	return "No Instructor Found."

It worked actually, it was just not working with bench execute.