mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
Added device registration information during authentication
This commit is contained in:
@@ -16,10 +16,10 @@ var TokenRequest = function (email, masterPasswordHash, token, device) {
|
|||||||
this.email = email;
|
this.email = email;
|
||||||
this.masterPasswordHash = masterPasswordHash;
|
this.masterPasswordHash = masterPasswordHash;
|
||||||
this.token = token;
|
this.token = token;
|
||||||
this.provider = 'Authenticator';
|
this.provider = 0; // authenticator
|
||||||
this.device = null;
|
this.device = null;
|
||||||
if (device) {
|
if (device) {
|
||||||
this.device = new DeviceRequest(device);
|
this.device = device;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.toIdentityToken = function () {
|
this.toIdentityToken = function () {
|
||||||
@@ -62,9 +62,9 @@ var DeviceTokenRequest = function () {
|
|||||||
this.pushToken = null;
|
this.pushToken = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
var DeviceRequest = function () {
|
var DeviceRequest = function (appId, utilsService) {
|
||||||
this.type = null;
|
this.type = utilsService.getDeviceType();
|
||||||
this.name = null;
|
this.name = utilsService.getBrowser();
|
||||||
this.identifier = null;
|
this.identifier = appId;
|
||||||
this.pushToken = null;
|
this.pushToken = null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
.module('bit.services')
|
.module('bit.services')
|
||||||
|
|
||||||
.factory('authService', function (cryptoService, apiService, userService, tokenService, $q, $rootScope, loginService,
|
.factory('authService', function (cryptoService, apiService, userService, tokenService, $q, $rootScope, loginService,
|
||||||
folderService, settingsService, syncService) {
|
folderService, settingsService, syncService, appIdService, utilsService) {
|
||||||
var _service = {};
|
var _service = {};
|
||||||
|
|
||||||
_service.logIn = function (email, masterPassword, twoFactorToken) {
|
_service.logIn = function (email, masterPassword, twoFactorToken) {
|
||||||
@@ -10,7 +10,9 @@
|
|||||||
var key = cryptoService.makeKey(masterPassword, email);
|
var key = cryptoService.makeKey(masterPassword, email);
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
cryptoService.hashPassword(masterPassword, key, function (hashedPassword) {
|
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) {
|
apiService.postIdentityToken(request, function (response) {
|
||||||
// success
|
// success
|
||||||
@@ -36,6 +38,7 @@
|
|||||||
deferred.reject(error);
|
deferred.reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,23 @@ function initUtilsService() {
|
|||||||
return this.analyticsIdCache;
|
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) {
|
UtilsService.prototype.initListSectionItemListeners = function (doc, angular) {
|
||||||
if (!doc) {
|
if (!doc) {
|
||||||
throw 'doc parameter required';
|
throw 'doc parameter required';
|
||||||
|
|||||||
Reference in New Issue
Block a user