$ git clone https://github.com/tariqiqbal27/authentication-system
$ cd authentication-system
$ npm install
- Edit the config.js file and enter database name
module.exports = {
MongoURL: 'mongodb://127.0.0.1:27017/your-database-name
}
- From within the authentication-system directory start the server
$ npm run dev
- Access the Server Api from localhost:3000
Request
POST /register
Body - JSON
{
"email":"[email protected]",
"password":"anythingthatyoulike"
}
Response - JSON
{
"code": "ACCOUNT_CREATED",
"msg": "User Created"
}
Request
POST /login
Body - JSON
{
"email":"[email protected]",
"password":"anythingthatyoulike"
}
Response - JSON
{
"id": "5d9908678d1d0e1144c87b2c"
}
Request
GET /user
Response - JSON
{
"_id": "5d9908678d1d0e1144c54c2c",
"email": "[email protected]",
"createdAt": "2019-10-05T21:17:27.379Z",
"updatedAt": "2019-10-05T21:17:27.379Z"
}
Request
GET /user/userid
Response - String
5d9908678d1d0e1144c54c2c
Request
POST /user/logout
Response - JSON
{
"code": "AUTH_LOGOUT_SUCCESS",
"msg": "Logout Successfully"
}
Request
PATCH /user/change_password
Body - JSON
{
"old_password":"password1",
"new_password":"password2"
}
Response - JSON
{
"code": "AUTH_PASSWORD_CHANGE",
"msg": "Password changes Successfully"
}
Request
DELETE /user/delete
Response
{
"code": "DELETED_OK",
"msg": "Account Deleted"
}
Response
{
"code": "AUTH_NOT_SUCCESS",
"msg": "User not Authenticated"
}
Response
{
"code": "AUTH_OK",
"msg": "User already authenticated"
}
Response
{
"code": "AUTH_MIN_PASSWORD",
"msg": "Password length must be greater than 7"
}
Response
{
"code": "EMAIL_ALREADY_EXIST",
"msg": "Email Already Exist"
}
Response
{
"code": "AUTH_BLANK_FIELD",
"msg": "Enter Email/Password"
}
Response
{
"code": "LOGIN_INVALID",
"msg": "Email & password wrong"
}
Response
{
"code": "AUTH_PASSWORD_INCORRECT",
"msg": "Incorrect Account Password"
}
Response
{
"code": "AUTH_PASSWORD_SAME",
"msg": "New Password cannot be old password"
}