mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-06 09:20:43 +01:00
rebuild tokenrequest obj on login api
This commit is contained in:
parent
fbb9ae38d5
commit
ff0fde161e
@ -24,31 +24,31 @@ var TokenRequest = function (email, masterPasswordHash, provider, token, remembe
|
|||||||
if (device) {
|
if (device) {
|
||||||
this.device = device;
|
this.device = device;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
this.toIdentityToken = function () {
|
TokenRequest.prototype.toIdentityToken = function () {
|
||||||
var obj = {
|
var obj = {
|
||||||
grant_type: 'password',
|
grant_type: 'password',
|
||||||
username: this.email,
|
username: this.email,
|
||||||
password: this.masterPasswordHash,
|
password: this.masterPasswordHash,
|
||||||
scope: 'api offline_access',
|
scope: 'api offline_access',
|
||||||
client_id: 'browser'
|
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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) {
|
var RegisterRequest = function (email, masterPasswordHash, masterPasswordHint, key) {
|
||||||
|
@ -55,6 +55,10 @@ function initApiService() {
|
|||||||
ApiService.prototype.postIdentityToken = function (tokenRequest, success, successWithTwoFactor, error) {
|
ApiService.prototype.postIdentityToken = function (tokenRequest, success, successWithTwoFactor, error) {
|
||||||
var self = this;
|
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({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: self.identityBaseUrl + '/connect/token',
|
url: self.identityBaseUrl + '/connect/token',
|
||||||
|
Loading…
Reference in New Issue
Block a user