| author | rougeronj |
| Fri, 03 Apr 2015 10:44:34 +0200 | |
| changeset 60 | 7d624c1013a3 |
| child 66 | 86f880fe5a25 |
| permissions | -rw-r--r-- |
|
60
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
1 |
(function(){ |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
2 |
'use strict'; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
3 |
|
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
4 |
angular.module('ammicoAuth',['ngRoute']) |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
5 |
.controller('authCtrl', function($rootScope, $routeParams, $modal){ |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
6 |
$modal.open({ |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
7 |
templateUrl: 'auth/' + $routeParams.action + '_modal.html', |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
8 |
controller: 'auth' + $routeParams.action + 'Ctrl' |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
9 |
}); |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
10 |
}) |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
11 |
.controller('authloginCtrl', function($modalInstance, $scope, authApi, $window, $http, $location, $rootScope){ |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
12 |
$scope.login = function(){ |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
13 |
authApi.login.save({username:$scope.username, password:$scope.password}, function(data){ |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
14 |
$rootScope.globals.userLogged = true; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
15 |
$window.sessionStorage.token = data.token; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
16 |
$http.defaults.headers.common.Authorization = 'Token ' + $window.sessionStorage.token; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
17 |
$modalInstance.close(); |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
18 |
$location.path('/books'); |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
19 |
}); |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
20 |
}; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
21 |
$scope.cancel = function () { |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
22 |
$modalInstance.dismiss('cancel'); |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
23 |
$location.path( '/' ); |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
24 |
}; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
25 |
}) |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
26 |
.controller('authlogoutCtrl', function($modalInstance, $scope, $window, $http, $location, $rootScope){ |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
27 |
delete $window.sessionStorage.token; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
28 |
$rootScope.globals.userLogged = false; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
29 |
delete $http.defaults.headers.common.Authorization; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
30 |
|
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
31 |
$scope.cancel = function () { |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
32 |
$modalInstance.close(); |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
33 |
$location.path( '/' ); |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
34 |
}; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
35 |
}) |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
36 |
.controller('authregisterCtrl', function($scope, $modalInstance, $location){ |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
37 |
$scope.register = function () { |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
38 |
}; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
39 |
$scope.back = function () { |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
40 |
$modalInstance.close(); |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
41 |
$location.path( '/auth/login' ); |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
42 |
}; |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
43 |
}); |
|
7d624c1013a3
add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title)
rougeronj
parents:
diff
changeset
|
44 |
})(); |