This commit is contained in:
Kyle Spearrin 2016-09-21 15:21:50 -04:00
parent 6281b1d106
commit 7d2a16c1f4
8 changed files with 30 additions and 19 deletions

View File

@ -16,7 +16,7 @@
<div class="list-section-item list-section-item-icon-input"> <div class="list-section-item list-section-item-icon-input">
<i class="fa fa-lock fa-lg fa-fw"></i> <i class="fa fa-lock fa-lg fa-fw"></i>
<label for="code" class="sr-only">Verification Code</label> <label for="code" class="sr-only">Verification Code</label>
<input id="code" type="number" name="Code" placeholder="Verification Code" ng-model="model.code"> <input id="code" type="text" name="Code" placeholder="Verification Code" ng-model="model.code">
</div> </div>
</div> </div>
<div class="list-section-footer"> <div class="list-section-footer">

View File

@ -1,7 +1,7 @@
angular angular
.module('bit.global') .module('bit.global')
.controller('mainController', function ($scope, $state) { .controller('mainController', function ($scope, $state, loginService, toastr) {
var self = this; var self = this;
self.currentYear = new Date().getFullYear(); self.currentYear = new Date().getFullYear();
self.animation = ''; self.animation = '';
@ -23,5 +23,11 @@
else if (msg.command === 'syncStarted') { else if (msg.command === 'syncStarted') {
$scope.$broadcast('syncStarted'); $scope.$broadcast('syncStarted');
} }
else if (msg.command === 'logout') {
loginService.logOut(function () {
toastr.warning('Your login session has expired.', 'Logged out');
$state.go('home');
});
}
}); });
}); });

View File

@ -10,7 +10,7 @@
$scope.logOut = function () { $scope.logOut = function () {
SweetAlert.swal({ SweetAlert.swal({
title: 'Log out', title: 'Log Out',
text: 'Are you sure you want to log out?', text: 'Are you sure you want to log out?',
type: 'warning', type: 'warning',
showCancelButton: true, showCancelButton: true,

View File

@ -21,7 +21,7 @@
<i class="fa fa-chevron-right fa-lg"></i> <i class="fa fa-chevron-right fa-lg"></i>
</a> </a>
<a class="list-section-item" href="" ng-click="logOut()"> <a class="list-section-item" href="" ng-click="logOut()">
Log out Log Out
</a> </a>
</div> </div>
</div> </div>

View File

@ -64,10 +64,6 @@
return item.name.toLowerCase(); return item.name.toLowerCase();
}; };
$scope.filterByFolder = function (folder) {
};
$scope.searchSites = function () { $scope.searchSites = function () {
if (!$scope.searchText) { if (!$scope.searchText) {
return; return;

View File

@ -1,4 +1,4 @@
function ApiService(tokenService) { function ApiService(tokenService) {
this.baseUrl = 'https://api.bitwarden.com'; this.baseUrl = 'https://api.bitwarden.com';
this.tokenService = tokenService; this.tokenService = tokenService;
@ -269,6 +269,11 @@ function initApiService() {
// Helpers // Helpers
function handleError(errorCallback, jqXHR, textStatus, errorThrown) { function handleError(errorCallback, jqXHR, textStatus, errorThrown) {
if (jqXHR.status === 401 || jqXHR.status === 403) {
chrome.runtime.sendMessage(null, { command: 'logout' });
return;
}
errorCallback(new ErrorResponse(jqXHR)); errorCallback(new ErrorResponse(jqXHR));
} }
}; };

View File

@ -1,4 +1,4 @@
function FolderService(cryptoService, userService, apiService) { function FolderService(cryptoService, userService, apiService) {
this.cryptoService = cryptoService; this.cryptoService = cryptoService;
this.userService = userService; this.userService = userService;
this.apiService = apiService; this.apiService = apiService;
@ -29,7 +29,7 @@ function initFolderService() {
chrome.storage.local.get(foldersKey, function (obj) { chrome.storage.local.get(foldersKey, function (obj) {
var folders = obj[foldersKey]; var folders = obj[foldersKey];
if (id in folders) { if (folders && id in folders) {
callback(new Folder(folders[id])); callback(new Folder(folders[id]));
return; return;
} }
@ -97,10 +97,14 @@ function initFolderService() {
request = new FolderRequest(folder); request = new FolderRequest(folder);
if (!folder.id) { if (!folder.id) {
self.apiService.postFolder(request, apiSuccess, handleError); self.apiService.postFolder(request, apiSuccess, function (response) {
handleError(response, deferred)
});
} }
else { else {
self.apiService.putFolder(folder.id, request, apiSuccess, handleError); self.apiService.putFolder(folder.id, request, apiSuccess, function (response) {
handleError(response, deferred)
});
} }
function apiSuccess(response) { function apiSuccess(response) {
@ -219,4 +223,8 @@ function initFolderService() {
}); });
}); });
}; };
function handleError(error, deferred) {
deferred.reject(error);
}
}; };

View File

@ -1,4 +1,4 @@
function SiteService(cryptoService, userService, apiService) { function SiteService(cryptoService, userService, apiService) {
this.cryptoService = cryptoService; this.cryptoService = cryptoService;
this.userService = userService; this.userService = userService;
this.apiService = apiService; this.apiService = apiService;
@ -43,7 +43,7 @@ function initSiteService() {
chrome.storage.local.get(sitesKey, function (obj) { chrome.storage.local.get(sitesKey, function (obj) {
var sites = obj[sitesKey]; var sites = obj[sitesKey];
if (id in sites) { if (sites && id in sites) {
callback(new Site(sites[id])); callback(new Site(sites[id]));
return; return;
} }
@ -254,10 +254,6 @@ function initSiteService() {
}; };
function handleError(error, deferred) { function handleError(error, deferred) {
if (error.status === 401 || error.status === 403) {
// TODO: logout
}
deferred.reject(error); deferred.reject(error);
} }
}; };