File tree Expand file tree Collapse file tree 3 files changed +8
-11
lines changed
Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ func (c *ApiController) GetProviders() {
6565 providers = object .GetMaskedProviders (providers , true , user )
6666 c .ResponseOk (providers )
6767 } else {
68- if ! c .IsPreviewMode () && ! c . RequireAdmin () {
68+ if ! c .RequireAdmin () {
6969 return
7070 }
7171 limit := util .ParseInt (limit )
Original file line number Diff line number Diff line change @@ -46,9 +46,10 @@ func (c *ApiController) GetGlobalStores() {
4646
4747 c .ResponseOk (stores )
4848 } else {
49- if ! c .IsPreviewMode () && ! c . RequireAdmin () {
49+ if ! c .RequireAdmin () {
5050 return
5151 }
52+
5253 limit := util .ParseInt (limit )
5354 count , err := object .GetStoreCount (field , value )
5455 if err != nil {
Original file line number Diff line number Diff line change @@ -113,6 +113,11 @@ func (c *ApiController) CheckSignedIn() (string, bool) {
113113}
114114
115115func (c * ApiController ) RequireAdmin () bool {
116+ disablePreviewMode , _ := beego .AppConfig .Bool ("disablePreviewMode" )
117+ if ! disablePreviewMode {
118+ return true
119+ }
120+
116121 if ! c .IsAdmin () {
117122 c .ResponseError ("this operation requires admin privilege" )
118123 return false
@@ -131,15 +136,6 @@ func (c *ApiController) IsAdmin() bool {
131136 return res
132137}
133138
134- func (c * ApiController ) IsPreviewMode () bool {
135- disablePreviewMode , _ := beego .AppConfig .Bool ("disablePreviewMode" )
136- if disablePreviewMode {
137- c .ResponseError ("this operation requires admin privilege" )
138- return false
139- }
140- return true
141- }
142-
143139func DenyRequest (ctx * context.Context ) {
144140 responseError (ctx , "Unauthorized operation" )
145141}
You can’t perform that action at this time.
0 commit comments