summaryrefslogtreecommitdiff
path: root/nexus/controllers/auth/login.go
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-03-29 22:52:46 +0530
committerBobby <[email protected]>2026-03-29 22:52:46 +0530
commit9eb9b7f4bd552a641235764f66483e1f940fcfd9 (patch)
treeda520b923b5e6758d5457b6233dd6671fc640914 /nexus/controllers/auth/login.go
parent65a143a0871c35989b7c7ea6723d39a0585c089e (diff)
downloadechoes-of-vaelun-main.tar.xz
echoes-of-vaelun-main.zip
feat: nexus account manager scaffold with auth, characters, realmsHEADmain
Diffstat (limited to 'nexus/controllers/auth/login.go')
-rw-r--r--nexus/controllers/auth/login.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/nexus/controllers/auth/login.go b/nexus/controllers/auth/login.go
new file mode 100644
index 0000000..4fd7ffd
--- /dev/null
+++ b/nexus/controllers/auth/login.go
@@ -0,0 +1,39 @@
+package auth
+
+import (
+ "nexus/services/auth"
+ "nexus/sessions"
+ authTypes "nexus/types/auth"
+ "nexus/utils/collections"
+ "nexus/utils/meta"
+ "nexus/utils/shortcuts"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+func Login(context *fiber.Ctx) error {
+ body, err := meta.Body[authTypes.LoginRequest](context)
+ if err != nil {
+ return shortcuts.RedirectWithFlash(context, "login", collections.Record[string, any]{
+ "Error": err.Error(),
+ })
+ }
+
+ req := meta.Request(context)
+
+ session, serviceErr := auth.Login(body, req.IP, req.Header("User-Agent"))
+ if serviceErr != nil {
+ return shortcuts.RedirectWithFlash(context, "login", collections.Record[string, any]{
+ "Error": serviceErr.Message,
+ })
+ }
+
+ sess := meta.Session(context)
+ if err := sessions.CreateSession(sess, session.AccountID); err != nil {
+ return shortcuts.RedirectWithFlash(context, "login", collections.Record[string, any]{
+ "Error": ErrSessionCreate,
+ })
+ }
+
+ return shortcuts.Redirect(context, "account")
+}