Initially, I used the standard login method you know /API/method/login but sometimes I need to perform some operation so now I am overriding the login function and writing whatever logic I want like below i want to validate branch and send key details as well in response if logged in successfully.
@frappe.whitelist(allow_guest = True)
def pos_login(usr,pwd):
login_manager = LoginManager()
login_manager.authenticate(usr,pwd)
login_manager.post_login()
validate_branch(login_manager.user)
if frappe.response['message'] == 'Logged In':
frappe.response['user'] = login_manager.user
frappe.response['key_details'] = generate_key(login_manager.user)