mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
Added device registration information during authentication
This commit is contained in:
parent
5a20f9de01
commit
4be033df71
@ -16,10 +16,10 @@ var TokenRequest = function (email, masterPasswordHash, token, device) {
|
||||
this.email = email;
|
||||
this.masterPasswordHash = masterPasswordHash;
|
||||
this.token = token;
|
||||
this.provider = 'Authenticator';
|
||||
this.provider = 0; // authenticator
|
||||
this.device = null;
|
||||
if (device) {
|
||||
this.device = new DeviceRequest(device);
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
this.toIdentityToken = function () {
|
||||
@ -62,9 +62,9 @@ var DeviceTokenRequest = function () {
|
||||
this.pushToken = null;
|
||||
};
|
||||
|
||||
var DeviceRequest = function () {
|
||||
this.type = null;
|
||||
this.name = null;
|
||||
this.identifier = null;
|
||||
var DeviceRequest = function (appId, utilsService) {
|
||||
this.type = utilsService.getDeviceType();
|
||||
this.name = utilsService.getBrowser();
|
||||
this.identifier = appId;
|
||||
this.pushToken = null;
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
.module('bit.services')
|
||||
|
||||
.factory('authService', function (cryptoService, apiService, userService, tokenService, $q, $rootScope, loginService,
|
||||
folderService, settingsService, syncService) {
|
||||
folderService, settingsService, syncService, appIdService, utilsService) {
|
||||
var _service = {};
|
||||
|
||||
_service.logIn = function (email, masterPassword, twoFactorToken) {
|
||||
@ -10,7 +10,9 @@
|
||||
var key = cryptoService.makeKey(masterPassword, email);
|
||||
var deferred = $q.defer();
|
||||
cryptoService.hashPassword(masterPassword, key, function (hashedPassword) {
|
||||
var request = new TokenRequest(email, hashedPassword, twoFactorToken);
|
||||
appIdService.getAppId(function (appId) {
|
||||
var deviceRequest = new DeviceRequest(appId, utilsService);
|
||||
var request = new TokenRequest(email, hashedPassword, twoFactorToken, deviceRequest);
|
||||
|
||||
apiService.postIdentityToken(request, function (response) {
|
||||
// success
|
||||
@ -36,6 +38,7 @@
|
||||
deferred.reject(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
|
@ -64,6 +64,23 @@ function initUtilsService() {
|
||||
return this.analyticsIdCache;
|
||||
}
|
||||
|
||||
UtilsService.prototype.getDeviceType = function () {
|
||||
if (this.isChrome()) {
|
||||
return 2;
|
||||
}
|
||||
else if (this.isFirefox()) {
|
||||
return 3;
|
||||
}
|
||||
else if (this.isEdge()) {
|
||||
return 5;
|
||||
}
|
||||
else if (this.isOpera()) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
UtilsService.prototype.initListSectionItemListeners = function (doc, angular) {
|
||||
if (!doc) {
|
||||
throw 'doc parameter required';
|
||||
|
Loading…
Reference in New Issue
Block a user