1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 05:43:41 +00:00
Files
browser/common/src/models/response/profileResponse.ts
Thomas Rittson 358260596b Add null check to electronStorageService.Save (#461)
* Add default value for ForcePasswordReset

* Add null check to electronStorageService instead

* Add default value to ForcePasswordReset

* Update electron/src/services/electronStorage.service.ts

* Fix indention issue from GH suggestion

Co-authored-by: Oscar Hinton <oscar@oscarhinton.com>
2021-08-20 16:01:50 +02:00

52 lines
2.3 KiB
TypeScript

import { BaseResponse } from './baseResponse';
import { ProfileOrganizationResponse } from './profileOrganizationResponse';
import { ProfileProviderOrganizationResponse } from './profileProviderOrganizationResponse';
import { ProfileProviderResponse } from './profileProviderResponse';
export class ProfileResponse extends BaseResponse {
id: string;
name: string;
email: string;
emailVerified: boolean;
masterPasswordHint: string;
premium: boolean;
culture: string;
twoFactorEnabled: boolean;
key: string;
privateKey: string;
securityStamp: string;
forcePasswordReset: boolean;
organizations: ProfileOrganizationResponse[] = [];
providers: ProfileProviderResponse[] = [];
providerOrganizations: ProfileProviderOrganizationResponse[] = [];
constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.name = this.getResponseProperty('Name');
this.email = this.getResponseProperty('Email');
this.emailVerified = this.getResponseProperty('EmailVerified');
this.masterPasswordHint = this.getResponseProperty('MasterPasswordHint');
this.premium = this.getResponseProperty('Premium');
this.culture = this.getResponseProperty('Culture');
this.twoFactorEnabled = this.getResponseProperty('TwoFactorEnabled');
this.key = this.getResponseProperty('Key');
this.privateKey = this.getResponseProperty('PrivateKey');
this.securityStamp = this.getResponseProperty('SecurityStamp');
this.forcePasswordReset = this.getResponseProperty('ForcePasswordReset') ?? false;
const organizations = this.getResponseProperty('Organizations');
if (organizations != null) {
this.organizations = organizations.map((o: any) => new ProfileOrganizationResponse(o));
}
const providers = this.getResponseProperty('Providers');
if (providers != null) {
this.providers = providers.map((o: any) => new ProfileProviderResponse(o));
}
const providerOrganizations = this.getResponseProperty('ProviderOrganizations');
if (providerOrganizations != null) {
this.providerOrganizations = providerOrganizations.map((o: any) => new ProfileProviderOrganizationResponse(o));
}
}
}