mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-09-21 10:40:13 +00:00
fix(auth): always serialize User.Role so admin (role 0) is not omitted
The Role field used json:"role,omitempty". Admin is RoleAdmin = 0, so an admin profile serialized without a `role` key. The admin-frontend gates the admin menu (user management, settings) on `role === 0`, and its normalizeRole helper defaults a missing role to non-admin, so admins lost the admin menu. Drop omitempty so role 0 is always sent. Add a regression test.
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ type User struct {
|
||||
Common
|
||||
Username string `json:"username,omitempty" gorm:"uniqueIndex"`
|
||||
Password string `json:"password,omitempty" gorm:"type:char(72)"`
|
||||
Role Role `json:"role,omitempty"`
|
||||
Role Role `json:"role"`
|
||||
AgentSecret string `json:"agent_secret,omitempty" gorm:"type:char(32)"`
|
||||
RejectPassword bool `json:"reject_password,omitempty"`
|
||||
TokenVersion uint64 `json:"-" gorm:"not null;default:0"`
|
||||
|
||||
Reference in New Issue
Block a user