# HG changeset patch # User rougeronj # Date 1428050674 -7200 # Node ID 7d624c1013a32e0c6e58629fca6c33ad4affd7a1 # Parent df402f454856b7b77196b63d5c2e9ad579da9832 add and repair auth module (it was not detected by mercurial anymore due to a cass problem on title) diff -r df402f454856 -r 7d624c1013a3 client/app/auth/auth.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/app/auth/auth.css Fri Apr 03 10:44:34 2015 +0200 @@ -0,0 +1,9 @@ +.auth{ + display:block; + margin:auto; +} + +.auth input{ + width: 300px; + margin: 10px 0; +} \ No newline at end of file diff -r df402f454856 -r 7d624c1013a3 client/app/auth/auth_controller.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/app/auth/auth_controller.js Fri Apr 03 10:44:34 2015 +0200 @@ -0,0 +1,44 @@ +(function(){ + 'use strict'; + + angular.module('ammicoAuth',['ngRoute']) + .controller('authCtrl', function($rootScope, $routeParams, $modal){ + $modal.open({ + templateUrl: 'auth/' + $routeParams.action + '_modal.html', + controller: 'auth' + $routeParams.action + 'Ctrl' + }); + }) + .controller('authloginCtrl', function($modalInstance, $scope, authApi, $window, $http, $location, $rootScope){ + $scope.login = function(){ + authApi.login.save({username:$scope.username, password:$scope.password}, function(data){ + $rootScope.globals.userLogged = true; + $window.sessionStorage.token = data.token; + $http.defaults.headers.common.Authorization = 'Token ' + $window.sessionStorage.token; + $modalInstance.close(); + $location.path('/books'); + }); + }; + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + $location.path( '/' ); + }; + }) + .controller('authlogoutCtrl', function($modalInstance, $scope, $window, $http, $location, $rootScope){ + delete $window.sessionStorage.token; + $rootScope.globals.userLogged = false; + delete $http.defaults.headers.common.Authorization; + + $scope.cancel = function () { + $modalInstance.close(); + $location.path( '/' ); + }; + }) + .controller('authregisterCtrl', function($scope, $modalInstance, $location){ + $scope.register = function () { + }; + $scope.back = function () { + $modalInstance.close(); + $location.path( '/auth/login' ); + }; + }); +})(); diff -r df402f454856 -r 7d624c1013a3 client/app/auth/auth_controller_test.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/app/auth/auth_controller_test.js Fri Apr 03 10:44:34 2015 +0200 @@ -0,0 +1,7 @@ +'use strict'; + +describe("auth_controller_test", function(){ + it("should assert something",function(){ + expect(true).toBe(true); + }) +}) \ No newline at end of file diff -r df402f454856 -r 7d624c1013a3 client/app/auth/login_modal.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/app/auth/login_modal.html Fri Apr 03 10:44:34 2015 +0200 @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff -r df402f454856 -r 7d624c1013a3 client/app/auth/logout_modal.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/app/auth/logout_modal.html Fri Apr 03 10:44:34 2015 +0200 @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff -r df402f454856 -r 7d624c1013a3 client/app/auth/register_modal.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/app/auth/register_modal.html Fri Apr 03 10:44:34 2015 +0200 @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file