- Comments explain what each function does and why - Fixed unused strconv import in queue.go - Better documentation for SMTP email service - Explained journalctl log parsing in logs.go - Clarified queue operations in queue.go
23 lines
642 B
Go
23 lines
642 B
Go
package auth
|
|
|
|
// Role represents a user's role in the system.
|
|
type Role string
|
|
|
|
// Predefined roles.
|
|
const (
|
|
RoleAdmin Role = "admin" // Full access to all features
|
|
RoleUser Role = "user" // Limited access (not currently used)
|
|
)
|
|
|
|
// Context holds the authenticated user's information.
|
|
// This is stored in the request context during authentication.
|
|
type Context struct {
|
|
UserID uint // The user's database ID
|
|
Username string // The user's username for display
|
|
Role Role // The user's role (admin or user)
|
|
}
|
|
|
|
// IsAdmin checks if the user has admin privileges.
|
|
func (c *Context) IsAdmin() bool {
|
|
return c.Role == RoleAdmin
|
|
}
|