mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-25 16:59:17 +01:00
apis for change email and change password
This commit is contained in:
parent
d98aeab0c8
commit
322dcf76ae
@ -6,9 +6,12 @@ import { CipherBulkShareRequest } from '../models/request/cipherBulkShareRequest
|
||||
import { CipherCollectionsRequest } from '../models/request/cipherCollectionsRequest';
|
||||
import { CipherRequest } from '../models/request/cipherRequest';
|
||||
import { CipherShareRequest } from '../models/request/cipherShareRequest';
|
||||
import { EmailRequest } from '../models/request/emailRequest';
|
||||
import { EmailTokenRequest } from '../models/request/emailTokenRequest';
|
||||
import { FolderRequest } from '../models/request/folderRequest';
|
||||
import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest';
|
||||
import { PasswordHintRequest } from '../models/request/passwordHintRequest';
|
||||
import { PasswordRequest } from '../models/request/passwordRequest';
|
||||
import { RegisterRequest } from '../models/request/registerRequest';
|
||||
import { TokenRequest } from '../models/request/tokenRequest';
|
||||
import { TwoFactorEmailRequest } from '../models/request/twoFactorEmailRequest';
|
||||
@ -32,6 +35,9 @@ export abstract class ApiService {
|
||||
postTwoFactorEmail: (request: TwoFactorEmailRequest) => Promise<any>;
|
||||
getProfile: () => Promise<ProfileResponse>;
|
||||
putProfile: (request: UpdateProfileRequest) => Promise<ProfileResponse>;
|
||||
postEmailToken: (request: EmailTokenRequest) => Promise<any>;
|
||||
postEmail: (request: EmailRequest) => Promise<any>;
|
||||
postPassword: (request: PasswordRequest) => Promise<any>;
|
||||
getAccountRevisionDate: () => Promise<number>;
|
||||
postPasswordHint: (request: PasswordHintRequest) => Promise<any>;
|
||||
postRegister: (request: RegisterRequest) => Promise<any>;
|
||||
|
7
src/models/request/emailRequest.ts
Normal file
7
src/models/request/emailRequest.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export class EmailRequest {
|
||||
newEmail: string;
|
||||
masterPasswordHash: string;
|
||||
newMasterPasswordHash: string;
|
||||
token: string;
|
||||
key: string;
|
||||
}
|
4
src/models/request/emailTokenRequest.ts
Normal file
4
src/models/request/emailTokenRequest.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export class EmailTokenRequest {
|
||||
newEmail: string;
|
||||
masterPasswordHash: string;
|
||||
}
|
5
src/models/request/passwordRequest.ts
Normal file
5
src/models/request/passwordRequest.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export class PasswordRequest {
|
||||
masterPasswordHash: string;
|
||||
newMasterPasswordHash: string;
|
||||
key: string;
|
||||
}
|
@ -12,9 +12,12 @@ import { CipherBulkShareRequest } from '../models/request/cipherBulkShareRequest
|
||||
import { CipherCollectionsRequest } from '../models/request/cipherCollectionsRequest';
|
||||
import { CipherRequest } from '../models/request/cipherRequest';
|
||||
import { CipherShareRequest } from '../models/request/cipherShareRequest';
|
||||
import { EmailRequest } from '../models/request/emailRequest';
|
||||
import { EmailTokenRequest } from '../models/request/emailTokenRequest';
|
||||
import { FolderRequest } from '../models/request/folderRequest';
|
||||
import { ImportDirectoryRequest } from '../models/request/importDirectoryRequest';
|
||||
import { PasswordHintRequest } from '../models/request/passwordHintRequest';
|
||||
import { PasswordRequest } from '../models/request/passwordRequest';
|
||||
import { RegisterRequest } from '../models/request/registerRequest';
|
||||
import { TokenRequest } from '../models/request/tokenRequest';
|
||||
import { TwoFactorEmailRequest } from '../models/request/twoFactorEmailRequest';
|
||||
@ -197,6 +200,69 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
}
|
||||
}
|
||||
|
||||
async postEmailToken(request: EmailTokenRequest): Promise<any> {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.apiBaseUrl + '/accounts/email-token', {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
credentials: this.getCredentials(),
|
||||
headers: new Headers({
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
'Authorization': authHeader,
|
||||
'Device-Type': this.deviceType,
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
if (response.status !== 200) {
|
||||
const error = await this.handleError(response, false);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
async postEmail(request: EmailRequest): Promise<any> {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.apiBaseUrl + '/accounts/email', {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
credentials: this.getCredentials(),
|
||||
headers: new Headers({
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
'Authorization': authHeader,
|
||||
'Device-Type': this.deviceType,
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
if (response.status !== 200) {
|
||||
const error = await this.handleError(response, false);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
async postPassword(request: PasswordRequest): Promise<any> {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.apiBaseUrl + '/accounts/password', {
|
||||
body: JSON.stringify(request),
|
||||
cache: 'no-cache',
|
||||
credentials: this.getCredentials(),
|
||||
headers: new Headers({
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
'Authorization': authHeader,
|
||||
'Device-Type': this.deviceType,
|
||||
}),
|
||||
method: 'POST',
|
||||
}));
|
||||
|
||||
if (response.status !== 200) {
|
||||
const error = await this.handleError(response, false);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
|
||||
async getAccountRevisionDate(): Promise<number> {
|
||||
const authHeader = await this.handleTokenState();
|
||||
const response = await fetch(new Request(this.apiBaseUrl + '/accounts/revision-date', {
|
||||
|
Loading…
Reference in New Issue
Block a user