mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-11-05 00:50:21 +00:00
feat: enhance authorization check for settings access
This commit is contained in:
1 parent
6dea3e19d2
commit
8c5023a650
1 file changed
+6
-2
@@ -20,8 +20,12 @@ import (
|
|||||||
// @Success 200 {object} model.CommonResponse[model.SettingResponse]
|
// @Success 200 {object} model.CommonResponse[model.SettingResponse]
|
||||||
// @Router /setting [get]
|
// @Router /setting [get]
|
||||||
func listConfig(c *gin.Context) (model.SettingResponse, error) {
|
func listConfig(c *gin.Context) (model.SettingResponse, error) {
|
||||||
_, isMember := c.Get(model.CtxKeyAuthorizedUser)
|
u, ok := c.Get(model.CtxKeyAuthorizedUser)
|
||||||
authorized := isMember // TODO || isViewPasswordVerfied
|
var authorized bool
|
||||||
|
if ok {
|
||||||
|
user := u.(*model.User)
|
||||||
|
authorized = user.Role == model.RoleAdmin
|
||||||
|
}
|
||||||
|
|
||||||
conf := model.SettingResponse{
|
conf := model.SettingResponse{
|
||||||
Config: *singleton.Conf,
|
Config: *singleton.Conf,
|
||||||
|
|||||||
Reference in new issue
Block a user