-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathauth.controller.js
More file actions
50 lines (49 loc) · 1.31 KB
/
auth.controller.js
File metadata and controls
50 lines (49 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const authService = require('./auth.service');
module.exports = {
signup: async (req, res, next) => {
try {
res.send(await authService.signup(req.body));
} catch (error) {
next(error);
}
},
login: async (req, res, next) => {
try {
res.send(await authService.login(req.body));
} catch (error) {
next(error);
}
},
protect: async (req, res, next) => {
try {
await authService.protect(req);
next();
} catch (error) {
next(error);
}
},
forgotPassword: async (req, res, next) => {
try {
let DTO = await authService.forgotPassword(req);
res.status(200).json(DTO);
} catch (error) {
next(error);
}
},
resetPassword: async (req, res, next) => {
try {
let DTO = await authService.resetPassword(req.body, req.params.token);
res.status(200).json(DTO);
} catch (error) {
next(error);
}
},
updatePassword: async (req, res, next) => {
try {
let DTO = await authService.updatePassword(req.user.id, req.body);
res.status(200).json(DTO);
} catch (error) {
next(error);
}
},
};