mirror of
https://github.com/bitwarden/browser
synced 2025-12-31 15:43:28 +00:00
[Reset Password v1] Update Temp Password (#446)
* [Reset Password v1] Update Temp Password * Updating router to protected for child classes to access
This commit is contained in:
@@ -78,6 +78,7 @@ import { TwoFactorRecoveryRequest } from '../models/request/twoFactorRecoveryReq
|
||||
import { UpdateDomainsRequest } from '../models/request/updateDomainsRequest';
|
||||
import { UpdateKeyRequest } from '../models/request/updateKeyRequest';
|
||||
import { UpdateProfileRequest } from '../models/request/updateProfileRequest';
|
||||
import { UpdateTempPasswordRequest } from '../models/request/updateTempPasswordRequest';
|
||||
import { UpdateTwoFactorAuthenticatorRequest } from '../models/request/updateTwoFactorAuthenticatorRequest';
|
||||
import { UpdateTwoFactorDuoRequest } from '../models/request/updateTwoFactorDuoRequest';
|
||||
import { UpdateTwoFactorEmailRequest } from '../models/request/updateTwoFactorEmailRequest';
|
||||
@@ -389,6 +390,10 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
return new ApiKeyResponse(r);
|
||||
}
|
||||
|
||||
putUpdateTempPassword(request: UpdateTempPasswordRequest): Promise<any> {
|
||||
return this.send('PUT', '/accounts/update-temp-password', request, true, false);
|
||||
}
|
||||
|
||||
// Folder APIs
|
||||
|
||||
async getFolder(id: string): Promise<FolderResponse> {
|
||||
|
||||
@@ -292,6 +292,7 @@ export class SyncService implements SyncServiceAbstraction {
|
||||
await this.cryptoService.setOrgKeys(response.organizations, response.providerOrganizations);
|
||||
await this.userService.setSecurityStamp(response.securityStamp);
|
||||
await this.userService.setEmailVerified(response.emailVerified);
|
||||
await this.userService.setForcePasswordReset(response.forcePasswordReset);
|
||||
|
||||
const organizations: { [id: string]: OrganizationData; } = {};
|
||||
response.organizations.forEach(o => {
|
||||
|
||||
@@ -18,6 +18,7 @@ const Keys = {
|
||||
organizationsPrefix: 'organizations_',
|
||||
providersPrefix: 'providers_',
|
||||
emailVerified: 'emailVerified',
|
||||
forcePasswordReset: 'forcePasswordReset',
|
||||
};
|
||||
|
||||
export class UserService implements UserServiceAbstraction {
|
||||
@@ -27,6 +28,7 @@ export class UserService implements UserServiceAbstraction {
|
||||
private kdf: KdfType;
|
||||
private kdfIterations: number;
|
||||
private emailVerified: boolean;
|
||||
private forcePasswordReset: boolean;
|
||||
|
||||
constructor(private tokenService: TokenService, private storageService: StorageService) { }
|
||||
|
||||
@@ -52,6 +54,11 @@ export class UserService implements UserServiceAbstraction {
|
||||
return this.storageService.save(Keys.emailVerified, emailVerified);
|
||||
}
|
||||
|
||||
setForcePasswordReset(forcePasswordReset: boolean) {
|
||||
this.forcePasswordReset = forcePasswordReset;
|
||||
return this.storageService.save(Keys.forcePasswordReset, forcePasswordReset);
|
||||
}
|
||||
|
||||
async getUserId(): Promise<string> {
|
||||
if (this.userId == null) {
|
||||
this.userId = await this.storageService.get<string>(Keys.userId);
|
||||
@@ -94,6 +101,13 @@ export class UserService implements UserServiceAbstraction {
|
||||
return this.emailVerified;
|
||||
}
|
||||
|
||||
async getForcePasswordReset(): Promise<boolean> {
|
||||
if (this.forcePasswordReset == null) {
|
||||
this.forcePasswordReset = await this.storageService.get<boolean>(Keys.forcePasswordReset);
|
||||
}
|
||||
return this.forcePasswordReset;
|
||||
}
|
||||
|
||||
async clear(): Promise<any> {
|
||||
const userId = await this.getUserId();
|
||||
|
||||
@@ -102,6 +116,7 @@ export class UserService implements UserServiceAbstraction {
|
||||
await this.storageService.remove(Keys.stamp);
|
||||
await this.storageService.remove(Keys.kdf);
|
||||
await this.storageService.remove(Keys.kdfIterations);
|
||||
await this.storageService.remove(Keys.forcePasswordReset);
|
||||
await this.clearOrganizations(userId);
|
||||
await this.clearProviders(userId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user