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:
43
auth/roles.go
Normal file
43
auth/roles.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package auth
|
||||
|
||||
type role string
|
||||
|
||||
const (
|
||||
roleUser role = "user"
|
||||
roleAdmin role = "admin"
|
||||
)
|
||||
|
||||
func (r role) String() string {
|
||||
return string(r)
|
||||
}
|
||||
|
||||
func (r role) IsValid() bool {
|
||||
return r == roleUser || r == roleAdmin
|
||||
}
|
||||
|
||||
func (r role) IsAdmin() bool {
|
||||
return r == roleAdmin
|
||||
}
|
||||
|
||||
func (r role) IsUser() bool {
|
||||
return r == roleUser
|
||||
}
|
||||
|
||||
// RoleOption describes a valid role for display in admin UIs.
|
||||
type RoleOption struct {
|
||||
Name string `json:"name"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// Roles returns every valid role with a display name and its underlying value.
|
||||
func Roles() []RoleOption {
|
||||
return []RoleOption{
|
||||
{Name: "User", Value: string(roleUser)},
|
||||
{Name: "Admin", Value: string(roleAdmin)},
|
||||
}
|
||||
}
|
||||
|
||||
// IsValidRole reports whether value is a valid role.
|
||||
func IsValidRole(value string) bool {
|
||||
return role(value).IsValid()
|
||||
}
|
||||
Reference in New Issue
Block a user