blob: f700716fcec6bc7ffed687633724e887732da177 (
plain)
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
|
package auth
import (
authService "dove/services/auth"
"dove/utils/meta"
"dove/utils/shortcuts"
"github.com/gofiber/fiber/v2"
)
func Login(context *fiber.Ctx) error {
body, parseError := meta.Body[authService.LoginRequest](context)
if parseError != nil {
return shortcuts.BadRequestError(context, parseError)
}
_, serviceError := authService.Authenticate(context, body)
if serviceError != nil {
return shortcuts.HandleError(context, serviceError)
}
return shortcuts.Redirect(context, "dashboard.index")
}
func Logout(context *fiber.Ctx) error {
_, serviceError := authService.Deauthenticate(context)
if serviceError != nil {
return shortcuts.HandleError(context, serviceError)
}
return shortcuts.Redirect(context, "home")
}
|