diff --git a/src/popup/app/accounts/accountsLoginController.js b/src/popup/app/accounts/accountsLoginController.js
index 39f2cd6f43..72adfa6e22 100644
--- a/src/popup/app/accounts/accountsLoginController.js
+++ b/src/popup/app/accounts/accountsLoginController.js
@@ -22,16 +22,12 @@
$scope.loginPromise.then(function () {
userService.isTwoFactorAuthenticated(function (isTwoFactorAuthenticated) {
if (isTwoFactorAuthenticated) {
- $state.go('login.twoFactor');
+ $state.go('twoFactor', { animation: 'in-slide-left' });
}
else {
- $state.go('tabs.current', { animation: 'in-slide-left' });
+ $state.go('tabs.vault', { animation: 'in-slide-left' });
}
});
});
};
-
- $scope.twoFactor = function (model) {
- $state.go('tabs.current');
- };
});
diff --git a/src/popup/app/accounts/accountsLoginTwoFactorController.js b/src/popup/app/accounts/accountsLoginTwoFactorController.js
new file mode 100644
index 0000000000..f8758217a9
--- /dev/null
+++ b/src/popup/app/accounts/accountsLoginTwoFactorController.js
@@ -0,0 +1,15 @@
+angular
+ .module('bit.accounts')
+
+ .controller('accountsLoginTwoFactorController', function ($scope, $state, loginService) {
+ popupUtils.initListSectionItemListeners();
+ $('#code').focus();
+
+ $scope.loginPromise = null;
+ $scope.login = function (model) {
+ $scope.loginPromise = loginService.logInTwoFactor(model.code);
+ $scope.loginPromise.then(function () {
+ $state.go('tabs.vault', { animation: 'in-slide-left' });
+ });
+ };
+ });
diff --git a/src/popup/app/accounts/views/accountsLoginTwoFactor.html b/src/popup/app/accounts/views/accountsLoginTwoFactor.html
index 04e55bf075..49e3accb8c 100644
--- a/src/popup/app/accounts/views/accountsLoginTwoFactor.html
+++ b/src/popup/app/accounts/views/accountsLoginTwoFactor.html
@@ -1,7 +1,28 @@
-
-
-
- Some content for your login.
-
-
-
+
diff --git a/src/popup/app/config.js b/src/popup/app/config.js
index 04adb82d8b..20db55133c 100644
--- a/src/popup/app/config.js
+++ b/src/popup/app/config.js
@@ -64,7 +64,7 @@
})
.state('twoFactor', {
url: '/two-factor',
- controller: 'accountsLoginController',
+ controller: 'accountsLoginTwoFactorController',
templateUrl: 'app/accounts/views/accountsLoginTwoFactor.html',
data: { authorize: false },
params: { animation: null }
diff --git a/src/popup/app/services/loginService.js b/src/popup/app/services/loginService.js
index 902d2c66a1..357f0b3e7f 100644
--- a/src/popup/app/services/loginService.js
+++ b/src/popup/app/services/loginService.js
@@ -21,9 +21,7 @@
if (response.profile) {
userService.setUserId(response.profile.id, function () {
userService.setEmail(response.profile.email, function () {
- syncService.fullSync(function () {
- $rootScope.$broadcast('syncCompleted');
- });
+ syncService.fullSync(function () { });
deferred.resolve(response);
});
});
@@ -44,7 +42,7 @@
var request = new TokenTwoFactorRequest(code);
var deferred = $q.defer();
- apiService.auth.postTokenTwoFactor(request, function (response) {
+ apiService.postTokenTwoFactor(request, function (response) {
if (!response || !response.token) {
deferred.reject();
return;
@@ -53,6 +51,7 @@
tokenService.setToken(response.token, function () {
userService.setUserId(response.profile.id, function () {
userService.setEmail(response.profile.email, function () {
+ syncService.fullSync(function () { });
deferred.resolve(response);
});
});
diff --git a/src/popup/index.html b/src/popup/index.html
index e2d3574805..85711fbaa3 100644
--- a/src/popup/index.html
+++ b/src/popup/index.html
@@ -52,6 +52,7 @@
+
diff --git a/src/services/apiService.js b/src/services/apiService.js
index ff2aad7de8..5007268b89 100644
--- a/src/services/apiService.js
+++ b/src/services/apiService.js
@@ -27,18 +27,20 @@ function initApiService() {
ApiService.prototype.postTokenTwoFactor = function (twoFactorTokenRequest, success, error) {
var self = this;
- $.ajax({
- type: 'POST',
- url: self.baseUrl + '/auth/token/two-factor',
- data: JSON.stringify(twoFactorTokenRequest),
- contentType: 'application/json; charset=utf-8',
- dataType: 'json',
- success: function (response) {
- success(new TokenResponse(response))
- },
- error: function (jqXHR, textStatus, errorThrown) {
- handleError(error, jqXHR, textStatus, errorThrown);
- }
+ this.tokenService.getToken(function (token) {
+ $.ajax({
+ type: 'POST',
+ url: self.baseUrl + '/auth/token/two-factor?access_token=' + token,
+ data: JSON.stringify(twoFactorTokenRequest),
+ contentType: 'application/json; charset=utf-8',
+ dataType: 'json',
+ success: function (response) {
+ success(new TokenResponse(response))
+ },
+ error: function (jqXHR, textStatus, errorThrown) {
+ handleError(error, jqXHR, textStatus, errorThrown);
+ }
+ });
});
};