Add IsMaskedEnabled to provider API

This commit is contained in:
Yang Luo
2023-05-19 13:09:53 +08:00
parent a9d662f1bd
commit de73ff0e60
4 changed files with 56 additions and 9 deletions

View File

@ -114,6 +114,27 @@ func (c *ApiController) RequireAdmin() (string, bool) {
return user.Owner, true
}
// IsMaskedEnabled ...
func (c *ApiController) IsMaskedEnabled() (bool, bool) {
isMaskEnabled := true
withSecret := c.Input().Get("withSecret")
if withSecret == "1" {
isMaskEnabled = false
if conf.IsDemoMode() {
c.ResponseError(c.T("general:this operation is not allowed in demo mode"))
return false, isMaskEnabled
}
_, ok := c.RequireAdmin()
if !ok {
return false, isMaskEnabled
}
}
return true, isMaskEnabled
}
func (c *ApiController) GetProviderFromContext(category string) (*object.Provider, *object.User, bool) {
providerName := c.Input().Get("provider")
if providerName != "" {