Is there a password_reset hook?

I have a requirement where i want an item for a doctype to be created when the user signup.

i can use ‘on_session_creation’ hook which gets called when the user logs into the system for the very first time aka while creating a new login session and validate whether the first item has been created for that user or not. this is working fine.

but, I have a flow where the user can signup via email and when they tap on the confirmation link in their email, the system asks them to reset the password. In this flow, the system is automatically logging in the user and also the ‘on_session_creation’ hook is not getting called.

Is there anyway for me to create an item in the doctype only when the user signup?

Or to put my question in another way: Is there a way for me to stop the session from getting created when the user resets their password for the first time when they do so via the signup confirmation link?

note: I’ve also posted this on SO

The thread header and the body seems to contradict. Are you trying to implement a function to force a user to change password when they login for the first time or you want to create a record when they login for the first time?

hi @flexy2ky, thank you for the response and my apologies for the confusion in the post, also i dont know how else to put it.

you want to create a record when they login for the first time?

-> yes my intention is to create a record when they login for the first time, which is happening as expectedly if the user logs in and I get a callback for ‘on_session_creation’ hook.

but, as mentioned in the question, when the user taps on the confirmation link in their signup confirmation email, they’re navigated to the create password screen and when they create the password, they’re logged in automatically(which is their very first login) and the ‘on_session_creation’ hook isn’t getting called in this flow.
So, my question is: Is there any way to get a callback in this flow so that I can create a record in this flow also.

I hope now my ask is clear, if not please feel free to raise concerns.

The easiest method I can think of is for you to create a custom frappe_whitelist function to handle login to and add a method to check if it’s first time login return a response you can then use to call the on_session_hook. We used this method to force a first time user logged in to change the default password given on account creation on a mobile app so I think it will work for you too.

hi @flexy2ky, thanks for the response again.

I believe you’re asking me to do something similar to this one, if so, can you please let me know how do i override the default login action? (note: I don’t want to create a custom login page)

Or are you referring to ‘on_login’ session hook?