aboutsummaryrefslogtreecommitdiff
path: root/controllers/auth
diff options
context:
space:
mode:
Diffstat (limited to 'controllers/auth')
-rw-r--r--controllers/auth/auth.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/controllers/auth/auth.go b/controllers/auth/auth.go
new file mode 100644
index 0000000..8140ddd
--- /dev/null
+++ b/controllers/auth/auth.go
@@ -0,0 +1,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")
+} \ No newline at end of file