1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +00:00

Added two factor flow into identity login

This commit is contained in:
Kyle Spearrin
2017-01-18 22:14:51 -05:00
parent 6bb6c7074b
commit 0b63eb58ba
8 changed files with 88 additions and 154 deletions

View File

@@ -12,9 +12,11 @@ var FolderRequest = function (folder) {
this.name = folder.name ? folder.name.encryptedString : null;
};
var TokenRequest = function (email, masterPasswordHash, device) {
var TokenRequest = function (email, masterPasswordHash, code, device) {
this.email = email;
this.masterPasswordHash = masterPasswordHash;
this.code = code;
this.provider = 'Authenticator';
this.device = null;
if (device) {
this.device = new DeviceRequest(device);
@@ -36,6 +38,11 @@ var TokenRequest = function (email, masterPasswordHash, device) {
obj.devicePushToken = this.device.pushToken;
}
if (this.code && this.provider) {
obj.twoFactorCode = this.code;
obj.twoFactorProvider = this.provider;
}
return obj;
};
};
@@ -51,12 +58,6 @@ var PasswordHintRequest = function (email) {
this.email = email;
};
var TokenTwoFactorRequest = function (code) {
this.code = code;
this.provider = "Authenticator";
this.device = null;
};
var DeviceTokenRequest = function () {
this.pushToken = null;
};

View File

@@ -38,14 +38,6 @@ var ProfileResponse = function (response) {
this.twoFactorEnabled = response.TwoFactorEnabled;
};
var TokenResponse = function (response) {
this.token = response.Token;
if (response.Profile) {
this.profile = new ProfileResponse(response.Profile);
}
};
var IdentityTokenResponse = function (response) {
this.accessToken = response.access_token;
this.expiresIn = response.expires_in;
@@ -59,10 +51,18 @@ var ListResponse = function (data) {
this.data = data;
};
var ErrorResponse = function (response) {
if (response.responseJSON) {
this.message = response.responseJSON.Message;
this.validationErrors = response.responseJSON.ValidationErrors;
var ErrorResponse = function (response, identityResponse) {
var errorModel = null;
if (identityResponse && identityResponse === true && response.responseJSON && response.responseJSON.ErrorModel) {
errorModel = response.responseJSON.ErrorModel;
}
else if (response.responseJSON) {
errorModel = response.responseJSON;
}
if (errorModel) {
this.message = errorModel.Message;
this.validationErrors = errorModel.ValidationErrors;
}
this.statusCode = response.status;
};