From ff0fde161e67bdea550b71747f8b9283c3442ff0 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 6 Sep 2017 15:52:06 -0400 Subject: [PATCH] rebuild tokenrequest obj on login api --- src/models/api/requestModels.js | 46 ++++++++++++++++----------------- src/services/apiService.js | 4 +++ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/models/api/requestModels.js b/src/models/api/requestModels.js index e98cd93f7d..ac9f836934 100644 --- a/src/models/api/requestModels.js +++ b/src/models/api/requestModels.js @@ -24,31 +24,31 @@ var TokenRequest = function (email, masterPasswordHash, provider, token, remembe if (device) { this.device = device; } +}; - this.toIdentityToken = function () { - var obj = { - grant_type: 'password', - username: this.email, - password: this.masterPasswordHash, - scope: 'api offline_access', - client_id: 'browser' - }; - - if (this.device) { - obj.deviceType = this.device.type; - obj.deviceIdentifier = this.device.identifier; - obj.deviceName = this.device.name; - obj.devicePushToken = this.device.pushToken; - } - - if (this.token && this.provider !== null && (typeof this.provider !== 'undefined')) { - obj.twoFactorToken = this.token; - obj.twoFactorProvider = this.provider; - obj.twoFactorRemember = this.remember ? '1' : '0'; - } - - return obj; +TokenRequest.prototype.toIdentityToken = function () { + var obj = { + grant_type: 'password', + username: this.email, + password: this.masterPasswordHash, + scope: 'api offline_access', + client_id: 'browser' }; + + if (this.device) { + obj.deviceType = this.device.type; + obj.deviceIdentifier = this.device.identifier; + obj.deviceName = this.device.name; + obj.devicePushToken = this.device.pushToken; + } + + if (this.token && this.provider !== null && (typeof this.provider !== 'undefined')) { + obj.twoFactorToken = this.token; + obj.twoFactorProvider = this.provider; + obj.twoFactorRemember = this.remember ? '1' : '0'; + } + + return obj; }; var RegisterRequest = function (email, masterPasswordHash, masterPasswordHint, key) { diff --git a/src/services/apiService.js b/src/services/apiService.js index cfc43b1ef8..b111d70eb0 100644 --- a/src/services/apiService.js +++ b/src/services/apiService.js @@ -55,6 +55,10 @@ function initApiService() { ApiService.prototype.postIdentityToken = function (tokenRequest, success, successWithTwoFactor, error) { var self = this; + // Hack for Edge. For some reason tokenRequest loses proto. Rebuild it here. + tokenRequest = new TokenRequest(tokenRequest.email, tokenRequest.masterPasswordHash, tokenRequest.provider, + tokenRequest.token, tokenRequest.remeber, tokenRequest.device); + $.ajax({ type: 'POST', url: self.identityBaseUrl + '/connect/token',