feat: implement user profile management with avatars, login, and personal data
- Add avatar upload functionality with public URL access. - Implement user login with email and password authentication. - Create endpoints for fetching and updating the authenticated user's profile. - Set up database migrations for user profiles, including email and role management. - Introduce personal data management linked to user profiles. - Add email verification process with welcome email templates.
This commit is contained in:
23
admin/middleware.go
Normal file
23
admin/middleware.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
authsvc "encore.app/auth"
|
||||
"encore.dev/beta/auth"
|
||||
"encore.dev/beta/errs"
|
||||
"encore.dev/middleware"
|
||||
)
|
||||
|
||||
// RequireAdmin ensures the caller is logged in and has the admin role
|
||||
// before any endpoint in this service runs.
|
||||
//
|
||||
//encore:middleware target=all
|
||||
func RequireAdmin(req middleware.Request, next middleware.Next) middleware.Response {
|
||||
if _, ok := auth.UserID(); !ok {
|
||||
return middleware.Response{Err: &errs.Error{Code: errs.Unauthenticated, Message: "must be logged in"}}
|
||||
}
|
||||
data, _ := auth.Data().(*authsvc.AuthData)
|
||||
if data == nil || !data.Role.IsAdmin() {
|
||||
return middleware.Response{Err: &errs.Error{Code: errs.PermissionDenied, Message: "admin role required"}}
|
||||
}
|
||||
return next(req)
|
||||
}
|
||||
Reference in New Issue
Block a user