Exemple #1
0
        public async Task <UserStorageInfo> GetUserStorageInfo(string userName = null)
        {
            var user = await _authManager.GetCurrentUser();

            if (user == null)
            {
                throw new BadRequestException("User does not exist");
            }

            if (string.IsNullOrWhiteSpace(userName))
            {
                return(_utils.GetUserStorage(user));
            }

            if (!await _authManager.IsUserAdmin())
            {
                throw new UnauthorizedException("Cannot get other user's storage info");
            }

            user = await _userManager.FindByNameAsync(userName);

            if (user == null)
            {
                throw new BadRequestException("Cannot find user " + userName);
            }

            return(_utils.GetUserStorage(user));
        }