1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-06 10:32:49 -05:00

More CanAccessPremium checks

This commit is contained in:
Kyle Spearrin
2018-08-28 17:40:08 -04:00
parent c41a1e0936
commit cf73b168ee
16 changed files with 90 additions and 48 deletions

View File

@ -3,12 +3,14 @@ using Bit.Core.Models.Table;
using System.Collections.Generic;
using System.Linq;
using Bit.Core.Models.Data;
using Bit.Core.Services;
namespace Bit.Core.Models.Api
{
public class ProfileResponseModel : ResponseModel
{
public ProfileResponseModel(User user, IEnumerable<OrganizationUserOrganizationDetails> organizationsUserDetails)
public ProfileResponseModel(User user,
IEnumerable<OrganizationUserOrganizationDetails> organizationsUserDetails, bool twoFactorEnabled)
: base("profile")
{
if(user == null)
@ -23,7 +25,7 @@ namespace Bit.Core.Models.Api
Premium = user.Premium;
MasterPasswordHint = string.IsNullOrWhiteSpace(user.MasterPasswordHint) ? null : user.MasterPasswordHint;
Culture = user.Culture;
TwoFactorEnabled = user.TwoFactorIsEnabled();
TwoFactorEnabled = twoFactorEnabled;
Key = user.Key;
PrivateKey = user.PrivateKey;
SecurityStamp = user.SecurityStamp;

View File

@ -12,6 +12,7 @@ namespace Bit.Core.Models.Api
public SyncResponseModel(
GlobalSettings globalSettings,
User user,
bool userTwoFactorEnabled,
IEnumerable<OrganizationUserOrganizationDetails> organizationUserDetails,
IEnumerable<Folder> folders,
IEnumerable<CollectionDetails> collections,
@ -20,7 +21,7 @@ namespace Bit.Core.Models.Api
bool excludeDomains)
: base("sync")
{
Profile = new ProfileResponseModel(user, organizationUserDetails);
Profile = new ProfileResponseModel(user, organizationUserDetails, userTwoFactorEnabled);
Folders = folders.Select(f => new FolderResponseModel(f));
Ciphers = ciphers.Select(c => new CipherDetailsResponseModel(c, globalSettings, collectionCiphersDict));
Collections = collections?.Select(