This Blog post will help you to add the password recovery functionalities in your clojure web application.
Firstly, create html file containing textbox for getting email address, on which a new passowrd will be sent.
Next, add this in your project.clj File
Now follow the given steps to add password recovery functionality:
Let’s define a forgot-password.clj namespace and import the following :
To get the random string we can use the following code:-
We also have to define the routes :-
The GET forgot-password route simply call the forgot-password function to render the page
Function to render the page using default luminus template:
The POST forgot-password route simply call the forgot-password-post function and pass the email as an argument
Define the forgot-password-post function in (testapp.routes.forgot-password.clj) . This function sends the password (a random string) to the given e-mail:
Note :- * This code may contain some validation which is applicable on email. Like:email-error (vali/on-error :email first)
Define “get-email”, “update-user-password” in namesapce “db” to get the email addressand to update the user password respectively.
“encrypt” from “noir.util.crypt” is used to encrypt the password.