100 lines
3.5 KiB
JavaScript
100 lines
3.5 KiB
JavaScript
var path = require('path');
|
|
const api_version = path.resolve(__dirname, '..').split(path.sep).pop();
|
|
const api_url = path.sep + api_version;
|
|
const { verifyPasswordStrength } = require('../middlewares/verifyPasswordStrength')
|
|
const { verifyRequestEmail } = require('../middlewares/verifyRequestEmail')
|
|
const { verifyTokenValidation } = require('../middlewares/verifyTokenValidation')
|
|
const { verifyJWT } = require('../middlewares/verifyJWT');
|
|
const { verifyPwned } = require('../middlewares/verifyPasswordPwned')
|
|
|
|
module.exports = function (application) {
|
|
|
|
/**
|
|
* Register on app
|
|
* @route POST /auth/signup
|
|
* @group Auth
|
|
* @param {object} auth.body email, password and confirm_password - eg:
|
|
* {
|
|
* "email": "some_email@gmail.com",
|
|
* "password": "example-password",
|
|
* "confirm_password": "example-password"
|
|
* }
|
|
* @returns {object} 200 - ok
|
|
* @returns {Error} default - Unexpected error
|
|
*/
|
|
application.post(api_url + '/auth/signup', [verifyRequestEmail, verifyPasswordStrength, verifyPwned], function (req, res) {
|
|
application.app[api_version].controllers.auth.signup(application, req, res);
|
|
});
|
|
|
|
/**
|
|
* Signin on app
|
|
* @route POST /auth/signin
|
|
* @group Auth
|
|
* @returns {object} 200 - ok
|
|
* @returns {Error} default - Unexpected error
|
|
*/
|
|
application.post(api_url + '/auth/signin', function (req, res) {
|
|
application.app[api_version].controllers.auth.signin(application, req, res);
|
|
});
|
|
|
|
/**
|
|
* Request password
|
|
* @route POST /auth/requestpassword
|
|
* @group Auth
|
|
* @param {object} auth.body with email - eg:
|
|
* {
|
|
* "email": "some_email@gmail.com"
|
|
* }
|
|
* @returns {object} 200 - ok
|
|
* @returns {Error} default - Unexpected error
|
|
*/
|
|
application.post(api_url + '/auth/requestpassword', [verifyRequestEmail], function (req, res) {
|
|
application.app[api_version].controllers.auth.requestpassword(application, req, res);
|
|
});
|
|
|
|
/**
|
|
* Recover password
|
|
* @route POST /auth/recoverpassword
|
|
* @group Auth
|
|
* @param {object} auth.body recover_token, email, password and confirm_password - eg:
|
|
* {
|
|
* "recover_token": "dba9d7e0-fca4-11ec-87a7-39ce22c34f83_1657054553",
|
|
* "email": "some_email@gmail.com"
|
|
* "password": "another-example-password",
|
|
* "confirm_password": "another-example-password"
|
|
* }
|
|
* @returns {object} 200 - ok
|
|
* @returns {Error} default - Unexpected error
|
|
*/
|
|
application.post(api_url + '/auth/recoverpassword', [verifyTokenValidation, verifyPasswordStrength, verifyPwned], function (req, res) {
|
|
application.app[api_version].controllers.auth.recoverpassword(application, req, res);
|
|
});
|
|
|
|
/**
|
|
* Change password
|
|
* @route POST /auth/changepassword
|
|
* @group Auth
|
|
* @param {object} auth.body password and confirm_password - eg:
|
|
* {
|
|
* "email": "some_email@gmail.com",
|
|
* "password": "another-example-password",
|
|
* "confirm_password": "another-example-password"
|
|
* }
|
|
* @returns {object} 200 - ok
|
|
* @returns {Error} default - Unexpected error
|
|
*/
|
|
application.post(api_url + '/auth/changepassword', [verifyJWT, verifyPasswordStrength, verifyPwned], function (req, res) {
|
|
application.app[api_version].controllers.auth.changepassword(application, req, res);
|
|
});
|
|
|
|
/**
|
|
* Delete user
|
|
* @route DELETE /auth/deleteaccount
|
|
* @group Auth
|
|
* @returns {object} 200 - ok
|
|
* @returns {Error} default - Unexpected error
|
|
*/
|
|
application.delete(api_url + '/auth/deleteaccount', [verifyJWT], function (req, res) {
|
|
application.app[api_version].controllers.auth.deleteaccount(application, req, res);
|
|
});
|
|
} |