summaryrefslogtreecommitdiff
path: root/processors
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-02-11 14:53:34 +0530
committerBobby <[email protected]>2026-02-11 14:53:34 +0530
commit3360be86fb6a595659c17f272d0c6072e512c154 (patch)
tree4b78aa8120909b596f219a0159a3532200a05b1a /processors
parentd87e08e0fc5911b2ff40604944448e1f0aaa31b7 (diff)
downloadcafe-3360be86fb6a595659c17f272d0c6072e512c154.tar.xz
cafe-3360be86fb6a595659c17f272d0c6072e512c154.zip
Implement OpenID authentication flow, including user session management and user info retrieval
Diffstat (limited to 'processors')
-rw-r--r--processors/processors.go1
-rw-r--r--processors/user.go29
2 files changed, 30 insertions, 0 deletions
diff --git a/processors/processors.go b/processors/processors.go
index d56cbde..f1d573e 100644
--- a/processors/processors.go
+++ b/processors/processors.go
@@ -5,4 +5,5 @@ import "github.com/gofiber/fiber/v2"
func Initialize(app *fiber.App) {
app.Use(metadata)
app.Use(request)
+ app.Use(user)
}
diff --git a/processors/user.go b/processors/user.go
new file mode 100644
index 0000000..171808f
--- /dev/null
+++ b/processors/user.go
@@ -0,0 +1,29 @@
+package processors
+
+import (
+ "cafe/repositories"
+ "cafe/session"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+func user(ctx *fiber.Ctx) error {
+ sess, err := session.Store.Get(ctx)
+ if err != nil {
+ return ctx.Next()
+ }
+
+ username := sess.Get("username")
+ if username == nil {
+ return ctx.Next()
+ }
+
+ user, err := repositories.GetUserByUsername(username.(string))
+ if err != nil {
+ return ctx.Next()
+ }
+
+ ctx.Locals("User", user)
+
+ return ctx.Next()
+}