Example #1
0
        public async Task<UserResponse> DeleteAsync(UserDeleteRequest request)
        {
            var deletingUser = await _userDataSrv.GetAsync(request.UserId);

            if (!HasPremission(request.RequestOwner, UserManagePremission.CanDelete) || 
                !HasAccessToManage(deletingUser, request.RequestOwner))
            {
                _securityLogger.LogDangeriousDeleteAttemp(request.RequestOwner, deletingUser);
                return UnauthorizedRequest();
            }
            await BaseBeforeDeleteAsync(deletingUser, request.RequestOwner);
            await _userDataSrv.DeleteAsync(deletingUser.Id);
            await BaseAfterDeleteAsync(deletingUser, request.RequestOwner);
            return Success();
        }