UpdateUser() works

This commit is contained in:
2022-11-18 23:33:07 +01:00
parent 55f53deadf
commit 35ef2175bc
8 changed files with 329 additions and 44 deletions
+10 -1
View File
@@ -29,7 +29,7 @@ func NewEmptyPermissions() PermissionSet {
}
}
var respoNotAuthorized = ginresp.InternAPIError(apierr.USER_AUTH_FAILED, "You are not authorized for this action", nil)
var respoNotAuthorized = ginresp.InternAPIError(401, apierr.USER_AUTH_FAILED, "You are not authorized for this action", nil)
func (ac *AppContext) CheckPermissionUserRead(userid int64) *ginresp.HTTPResponse {
p := ac.permissions
@@ -42,3 +42,12 @@ func (ac *AppContext) CheckPermissionUserRead(userid int64) *ginresp.HTTPRespons
return langext.Ptr(respoNotAuthorized)
}
func (ac *AppContext) CheckPermissionUserAdmin(userid int64) *ginresp.HTTPResponse {
p := ac.permissions
if p.ReferenceID != nil && *p.ReferenceID == userid && p.KeyType == PermKeyTypeUserAdmin {
return nil
}
return langext.Ptr(respoNotAuthorized)
}