2016-10-03 17:42:19 +08:00
|
|
|
/**
|
|
|
|
* @ngdoc function
|
|
|
|
* @name passmanApp.controller:MainCtrl
|
|
|
|
* @description
|
|
|
|
* # MainCtrl
|
|
|
|
* Controller of the passmanApp
|
|
|
|
*/
|
|
|
|
angular.module('passmanApp')
|
2016-10-04 05:00:46 +08:00
|
|
|
.controller('PublicSharedCredential', ['$scope', 'ShareService','$window', function ($scope, ShareService, $window) {
|
2016-10-03 17:42:19 +08:00
|
|
|
$scope.test = 'hello world';
|
2016-10-06 00:24:36 +08:00
|
|
|
//@TODO Add download files
|
2016-10-03 17:42:19 +08:00
|
|
|
$scope.loading = false;
|
|
|
|
$scope.loadSharedCredential = function () {
|
|
|
|
$scope.loading = true;
|
2016-10-04 06:19:46 +08:00
|
|
|
var data = window.atob($window.location.hash.replace('#','')).split('<::>');
|
|
|
|
var guid = data[0];
|
|
|
|
var _key = data[1];
|
2016-10-04 05:00:46 +08:00
|
|
|
ShareService.getPublicSharedCredential(guid).then(function (sharedCredential) {
|
2016-10-03 17:42:19 +08:00
|
|
|
$scope.loading = false;
|
2016-10-04 05:00:46 +08:00
|
|
|
if(sharedCredential.status === 200){
|
2016-10-04 06:19:46 +08:00
|
|
|
var _credential = ShareService.decryptSharedCredential(sharedCredential.data.credential_data, _key);
|
|
|
|
$scope.shared_credential = _credential;
|
2016-10-04 05:00:46 +08:00
|
|
|
} else {
|
|
|
|
$scope.expired = true;
|
|
|
|
}
|
|
|
|
|
2016-10-03 17:42:19 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}])
|
|
|
|
;
|
|
|
|
|