1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-04 01:22:50 -05:00

organizations to account profile

This commit is contained in:
Kyle Spearrin
2017-03-02 21:51:03 -05:00
parent 0b87e2c57e
commit b18b6a44ef
4 changed files with 26 additions and 5 deletions

View File

@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Identity;
using Bit.Core.Domains;
using Bit.Core.Enums;
using System.Linq;
using Bit.Core.Repositories;
namespace Bit.Api.Controllers
{
@ -18,15 +19,18 @@ namespace Bit.Api.Controllers
{
private readonly IUserService _userService;
private readonly ICipherService _cipherService;
private readonly IOrganizationRepository _organizationRepository;
private readonly UserManager<User> _userManager;
public AccountsController(
IUserService userService,
ICipherService cipherService,
IOrganizationRepository organizationRepository,
UserManager<User> userManager)
{
_userService = userService;
_cipherService = cipherService;
_organizationRepository = organizationRepository;
_userManager = userManager;
}
@ -155,7 +159,8 @@ namespace Bit.Api.Controllers
public async Task<ProfileResponseModel> GetProfile()
{
var user = await _userService.GetUserByPrincipalAsync(User);
var response = new ProfileResponseModel(user);
var organizations = await _organizationRepository.GetManyByUserIdAsync(user.Id);
var response = new ProfileResponseModel(user, organizations);
return response;
}
@ -165,7 +170,7 @@ namespace Bit.Api.Controllers
{
var user = await _userService.GetUserByPrincipalAsync(User);
await _userService.SaveUserAsync(model.ToUser(user));
var response = new ProfileResponseModel(user);
var response = new ProfileResponseModel(user, null);
return response;
}