mirror of
https://github.com/Foltik/Shimapan
synced 2024-11-30 22:41:47 -05:00
Merge branch 'mean' of https://github.com/Foltik/shimapan into mean
This commit is contained in:
commit
123672dbfb
@ -1,4 +1,4 @@
|
||||
function UploadController($scope, Upload, $timeout) {
|
||||
function UploadController($scope, Upload, $timeout, AuthService) {
|
||||
$scope.errToString = function(err) {
|
||||
if (err === 'maxSize')
|
||||
return "File too large.";
|
||||
@ -14,7 +14,9 @@ function UploadController($scope, Upload, $timeout) {
|
||||
file.upload = Upload.upload({
|
||||
url: '/upload',
|
||||
method: 'POST',
|
||||
// data: loginToken, unique id, something
|
||||
headers: {
|
||||
'Authorization': AuthService.getAuthHeader()
|
||||
},
|
||||
file: file
|
||||
});
|
||||
|
||||
@ -36,7 +38,7 @@ function UploadController($scope, Upload, $timeout) {
|
||||
};
|
||||
}
|
||||
|
||||
angular.module('UploadComp', ['ngFileUpload']).component('uploadComponent', {
|
||||
angular.module('UploadComp', ['ngFileUpload', 'AuthSvc']).component('uploadComponent', {
|
||||
templateUrl: '/views/upload-form.html',
|
||||
controller: UploadController,
|
||||
controllerAs: 'vm'
|
||||
|
@ -18,6 +18,11 @@ angular.module('AuthSvc', []).service('AuthService', ['$http', '$window', functi
|
||||
return $window.localStorage['shimapan-token'];
|
||||
}
|
||||
|
||||
this.getAuthHeader = function() {
|
||||
return 'Bearer ' + getToken();
|
||||
};
|
||||
|
||||
|
||||
this.login = function(user) {
|
||||
return $http({
|
||||
method: 'POST',
|
||||
|
Loading…
Reference in New Issue
Block a user