Authify Node.js Express.js MongoDB JWT Google OAuth NodeMailer Hashing
Authify is a RESTful API supporting email and Google-based authentications, providing secure and seamless user authentication processes.
Authify is a RESTful API that supports secure user authentication via email and Google-based methods. Users can sign up with an email, generating a unique JWT token, and sign in using either email or Google authentication. The API also enables fetching user details from the JWT token.
The API offers features such as password reset through OTP sent to the registered email and supports account deletion. Additionally, it includes two-factor authentication to enhance security.
Authify provides real-time email notifications for all account activities, such as login events, password modifications, and other relevant actions, ensuring users are promptly informed of any changes to their accounts.
POST https : //api-authify.azurewebsites.net/auth/signup/email
Parameter Type Description email
string
Required Email Address
javascript:
const createNewUserViaEmail = await fetch ( 'https://api-authify.azurewebsites.net/signup/email' , {
method : 'POST' ,
headers : {
'Content-Type' : 'application/json'
},
body : JSON . stringify ({ email : credentials . email })
});
const json = await createNewUserViaEmail . json ();
console . log ( json );
{ "success" : true ,}
POST https : //api-authify.azurewebsites.net/auth/signup/email/verify
Parameter Type Description name
string
Required Name (min length : 3)email
string
Required Email addpassword
string
Required password (min length : 8)authcode
number
Required password (length : 6)
javascript:
const createNewUser = await fetch (
"https://api-authify.azurewebsites.net/auth/signup" ,
{
method : "POST" ,
headers : {
"Content-Type" : "application/json" ,
},
body : JSON . stringify ({
name : credentials . name ,
email : credentials . email ,
password : credentials . password ,
authcode : credentials . authCode
}),
}
);
const response = await createNewUser . json ();
console . log ( json );
{
"success" : true ,
"authToken" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXIiOiI2MjljN2YzYWVmMzEwNjg4N2EyYWNkZDAifSwiaWF0IjoxNjU0NDIzMzU1fQ.R1rX4sRHv-o3gDWT3XqtobYEKeYRmyvA8ZLpveobuGc"
}
POST https : //api-authify.azurewebsites.net/auth/signin
Parameter Type Description email
string
Required Email addresspassword
string
Required password (min length : 8)
javascript:
const signInUser = await fetch (
"https://api-authify.azurewebsites.net/auth/signin" ,
{
method : "POST" ,
headers : {
"Content-Type" : "application/json" ,
},
body : JSON . stringify ({
email : credentials . email ,
password : credentials . password ,
}),
}
);
const response = await signInUser . json ();
console . log ( json );
{
"success" : true ,
"authToken" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXIiOiI2MjljN2YzYWVmMzEwNjg4N2EyYWNkZDAifSwiaWF0IjoxNjU0NDIzMzU1fQ.R1rX4sRHv-o3gDWT3XqtobYEKeYRmyvA8ZLpveobuGc"
}
POST https : //api-authify.azurewebsites.net/auth/verifyuser
Parameter Type Description Content-Type
string
Required application/jsonauth-token
string
Required eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1.....
javascript:
const getUser = await fetch (
"https://api-authify.azurewebsites.net/auth/verifyuser" ,
{
method : "POST" ,
headers : {
"Content-Type" : "application/json" ,
"auth-token" :
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXIiOiI2MjljN2YzYWVmMzEwNjg4N2EyYWNkZDAifSwiaWF0IjoxNjU0NDIzMzU1fQ.R1rX4sRHv-o3gDWT3XqtobYEKeYRmyvA8ZLpveobuGc" ,
},
}
);
const response = await getUser . json ();
console . log ( json );
{
"_id" : "629c7f3aef3106887a2acdd0" ,
"name" : "user" ,
"email" : "userEmail@fudnef.com" ,
"googleId" : null ,
"date" : "2022-06-05T10:02:34.938Z" ,
"__v" : 0
}
Can be used for both resetting the password and updation of password
POST https : //api-authify.azurewebsites.net/fogotpassword
Parameter Type Description email
string
Required . Email address
javascript:
const sendMail = await fetch (
"https://api-authify.azurewebsites.net/fogotpassword" ,
{
method : "POST" ,
headers : {
"Content-Type" : "application/json" ,
},
body : JSON . stringify ({ email : credentials . email }),
}
);
const response = await sendMail . json ();
console . log ( response );
{
"success" : true ,
"message" : "Email Send"
}
POST https : //api-authify.azurewebsites.net/fogotpassword/verify
Parameter Type Description email
string
Required . Email addressauthcode
number
Required . OTP (6 digit)password
string
Required . new password (min length : 8)
javascript:
const changePassword = await fetch (
"https://api-authify.azurewebsites.net/fogotpassword/verify" ,
{
method : "POST" ,
headers : {
"Content-Type" : "application/json" ,
},
body : JSON . stringify ({
email : credentials . email ,
authcode : Number ( credentials . OTP ),
password : credentials . password ,
}),
}
);
const response = await changePassword . json ();
{
"success" : true ,
"msg" : "Password Updated"
}
To authenticate with google, you need to pass your app url as a query parameter in the url. Once the user authenticates with google, the user will be redirected to the app url with the auth token as a query parameter. You can fetch the token from the url and use it for further authentication.
PUT https://api-authify.azurewebsites.net/auth/google?url={YOUR_APP_URL}
html:
<!-- Redirection to Oauth screen and trigger initialization -->
< a href = 'https://api-authify.azurewebsites.net/auth/google?url={YOUR_APP_URL}' target = '_blank' >Continue with Google </ a >
https : //www.mrdhruv.co/?authToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InVzZXIiOiI2NjFlODljYmJlNjgzMzc1N2FiNTUxY2YifSwiaWF0IjoxNzEzMjc3NDUyfQ.n8_WjYngosSCByfeQgtyx51hVle6p1eRY6QcdZojOSs
POST https : //api-authify.azurewebsites.net/auth/delete/email
Parameter Type Description email
string
Required Email address
javascript:
const deleteGen = await fetch ( 'https://api-authify.azurewebsites.net/autdelete/email' , {
method : 'POST' ,
headers : {
'Content-Type' : 'application/json'
},
body : JSON . stringify ({ email : user . email })
})
const response = await deleteGen . json ();
console . log ( response )
{ "success" : true ,}
POST https : //api-authify.azurewebsites.net/auth/delete/email
Parameter Type Description email
string
Required Email addressauthcode
number
Required OTP (6 digit)password
string
Required Password (min-length : 8)
javascript:
const response = await fetch ( 'https://api-authify.azurewebsites.net/auth/delete/email/verify' , {
method : 'POST' ,
headers : {
'Content-Type' : 'application/json'
},
body : JSON . stringify ({ email : user . email , authcode : Number ( credentials . verifyToken ), password : credentials . password })
})
const response = await deleteGen . json ();
console . log ( response )
{ "success" : true ,}