fix: redirect users based on role after login

- Admin users redirect to /admin dashboard
- Regular users redirect to home page /
- Prevents authorization errors for non-admin users

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 19:05:39 +08:00
co-authored by Claude Fable 5
parent aca4983447
commit eb9a65097e
+5
View File
@@ -55,7 +55,12 @@ func Login(db *gorm.DB) gin.HandlerFunc {
return
}
// Redirect based on user role: admins to /admin, others to home
if user.Role == models.RoleAdmin {
c.Redirect(http.StatusFound, "/admin")
} else {
c.Redirect(http.StatusFound, "/")
}
}
}