Sign In
Let's start integrating the signIn function from the Email Armor module into your project for secure user authentication.
Configuring the signIn
function
1. Integration (POST Request)
To set up the signIn function within your API file, follow the steps below:
Note: Feel free to use your own method of input handling. Just ensure that if you pass an email, you do not pass the
username
, and vice versa.
2. Error Responses
Status | Message |
---|---|
400 | Either userName or userEmail must be provided! |
400 | Invalid userName! |
400 | Invalid Email! |
400 | Please Validate Your Details. |
401 | Your device is unauthorized. |
500 | An unexpected error occurred. Please report this issue at GitHub |
3. Success Response
Once you get a 202
response, it means the login was successful. The response will include the following details:
Note: If the user has enabled 2FA (Two-Factor Authentication), a
201
response will be received with an emptysignedJWTToken
(""
). Please refer to the following guidelines to complete the two-step verification setup. You should still save the cookies forid
anduserName
, but thetoken
will remain an empty string (""
).
Here is a sample of the response when 2FA is enabled:
4. Storing Cookies
After receiving the 202
response, you should store the id
, userName
, and signedJWTToken
in cookies. Below is an example of how to store these values using Next.js:
Note: You can use any method of cookie storage depending upon your tech stack.