mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
feat: enhance authorization check for settings access
This commit is contained in:
parent
4af7e83004
commit
f10e048bec
@ -20,8 +20,12 @@ import (
|
||||
// @Success 200 {object} model.CommonResponse[model.SettingResponse]
|
||||
// @Router /setting [get]
|
||||
func listConfig(c *gin.Context) (model.SettingResponse, error) {
|
||||
_, isMember := c.Get(model.CtxKeyAuthorizedUser)
|
||||
authorized := isMember // TODO || isViewPasswordVerfied
|
||||
u, ok := c.Get(model.CtxKeyAuthorizedUser)
|
||||
var authorized bool
|
||||
if ok {
|
||||
user := u.(*model.User)
|
||||
authorized = user.Role == model.RoleAdmin
|
||||
}
|
||||
|
||||
conf := model.SettingResponse{
|
||||
Config: *singleton.Conf,
|
||||
|
Loading…
Reference in New Issue
Block a user