Skip to content

Commit

Permalink
#152 [Backend] Check Email Verification Student
Browse files Browse the repository at this point in the history
  • Loading branch information
fdhhhdjd committed Feb 26, 2023
1 parent b839c0b commit b4fa7ee
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,38 @@ module.exports = {
* @created_at 23/02/2023
* @description Insert reset password student
*/
insertResetPassword: (data) =>
new Promise((resolve, reject) => {
try {
const result = knex('reset_password')
.insert(data)
.onConflict('id')
.merge()
.returning(['id', 'user_id']);
resolve(result);
} catch (error) {
reject(error);
}
}),
};
insertResetPassword: (data) => new Promise((resolve, reject) => {
try {
const result = knex('reset_password')
.insert(data)
.onConflict('id')
.merge()
.returning(['id', 'user_id']);
resolve(result);
} catch (error) {
reject(error);
}
}),
/**
* @author Nguyễn Tiến Tài
* @created_at 24/02/2023
* @description Get reset_token info by ID
*/
getResetPasswordById: async (student_query, return_data) => {
const student = await knex('reset_password').select(return_data).where(student_query);
return student;
},
/**
* @author Nguyễn Tiến Tài
* @created_at 24/02/2023
* @description Update reset Password
*/
updateResetPassword: async (data, student_query, return_data) => new Promise((resolve, reject) => {
try {
const result = knex('reset_password').update(data).where(student_query).returning(return_data);
resolve(result);
} catch (error) {
reject(error);
}
}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,8 @@ const userController = {
*/
resetPasswordStudent: async (req, res) => {
const { password, confirmPassword } = req.body.input.user_reset_password_input;

// Take Param Routes
const token_reset = req.params.token_reset;

// Check input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@ router.post('/renew-token', userController.reNewToken);
*/
router.post('/forget-password', userController.forgetPasswordStudent);

/**
* @author Nguyễn Tiến Tài
* @created_at 23/02/2023
* @description Route forget password Student
* @param {('POST')} [method='POST'] The request's method
*/
router.post('/reset/:token_reset', userController.resetPasswordStudent);

module.exports = router;

0 comments on commit b4fa7ee

Please sign in to comment.