Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jun 15, 2024
2 parents d29174c + 8bdd59a commit 6efa948
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/stage/protyle/js/lute/lute.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions kernel/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/sync/listCloudSyncDir", model.CheckAuth, model.CheckAdminRole, listCloudSyncDir)
ginServer.Handle("POST", "/api/sync/performSync", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, performSync)
ginServer.Handle("POST", "/api/sync/performBootSync", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, performBootSync)
ginServer.Handle("POST", "/api/sync/getBootSync", model.CheckAuth, model.CheckAdminRole, getBootSync)
ginServer.Handle("POST", "/api/sync/getBootSync", model.CheckAuth, getBootSync)
ginServer.Handle("POST", "/api/sync/getSyncInfo", model.CheckAuth, model.CheckAdminRole, getSyncInfo)
ginServer.Handle("POST", "/api/sync/exportSyncProviderS3", model.CheckAuth, model.CheckAdminRole, exportSyncProviderS3)
ginServer.Handle("POST", "/api/sync/importSyncProviderS3", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, importSyncProviderS3)
Expand Down Expand Up @@ -316,7 +316,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/setting/setSearch", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSearch)
ginServer.Handle("POST", "/api/setting/setKeymap", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setKeymap)
ginServer.Handle("POST", "/api/setting/setAppearance", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setAppearance)
ginServer.Handle("POST", "/api/setting/getCloudUser", model.CheckAuth, model.CheckAdminRole, getCloudUser)
ginServer.Handle("POST", "/api/setting/getCloudUser", model.CheckAuth, getCloudUser)
ginServer.Handle("POST", "/api/setting/logoutCloudUser", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, logoutCloudUser)
ginServer.Handle("POST", "/api/setting/login2faCloudUser", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, login2faCloudUser)
ginServer.Handle("POST", "/api/setting/setEmoji", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setEmoji)
Expand Down
4 changes: 4 additions & 0 deletions kernel/api/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,10 @@ func getCloudUser(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

if !model.IsAdminRoleContext(c) {
return
}

arg, ok := util.JsonArg(c, ret)
if !ok {
return
Expand Down
4 changes: 4 additions & 0 deletions kernel/api/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ func getBootSync(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

if !model.IsAdminRoleContext(c) {
return
}

if model.Conf.Sync.Enabled && 1 == model.BootSyncSucc {
ret.Code = 1
ret.Msg = model.Conf.Language(17)
Expand Down
4 changes: 4 additions & 0 deletions kernel/model/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ func GetGinContextRole(c *gin.Context) Role {
return RoleVisitor
}
}

func IsAdminRoleContext(c *gin.Context) bool {
return GetGinContextRole(c) == RoleAdministrator
}

0 comments on commit 6efa948

Please sign in to comment.