# HG changeset patch # User rougeronj # Date 1434029802 -7200 # Node ID 76fb2dd72ce4adb4a7741b1a86f0388018368623 # Parent 4b1294eaec0ac69f22d28d08ecd0d0d4020ca74a update auth controller to fit to the new server side authentication diff -r 4b1294eaec0a -r 76fb2dd72ce4 client/app/auth/auth.css --- a/client/app/auth/auth.css Thu Jun 11 15:36:07 2015 +0200 +++ b/client/app/auth/auth.css Thu Jun 11 15:36:42 2015 +0200 @@ -6,4 +6,16 @@ .auth input{ width: 300px; margin: 10px 0; +} + +.ng-invalid { + border-color: red; + outline-color: red; +} + +.messages { + font-size: smaller; + padding-top: 5px; + padding-bottom: 10px; + color: red; } \ No newline at end of file diff -r 4b1294eaec0a -r 76fb2dd72ce4 client/app/auth/auth_controller.js --- a/client/app/auth/auth_controller.js Thu Jun 11 15:36:07 2015 +0200 +++ b/client/app/auth/auth_controller.js Thu Jun 11 15:36:42 2015 +0200 @@ -1,7 +1,7 @@ (function(){ 'use strict'; - angular.module('ammicoAuth',['ngRoute']) + angular.module('ammicoAuth',['ngRoute', 'ngMessages']) .controller('authCtrl', function($location, $rootScope, $routeParams, $modal){ $modal.open({ templateUrl: 'auth/' + $routeParams.action + '_modal.html', @@ -37,16 +37,49 @@ }; }) .controller('authregisterCtrl', function($scope, $modalInstance, authApi){ - $scope.register = function () { - authApi.user.save({ - email: $scope.email, - password: $scope.password, - }, function(){ - $modalInstance.close('/auth/login'); - }); + $scope.message = ""; + + $scope.user = { + email: "", + password: "", + confirmPassword: "" + }; + + $scope.submit = function(isValid) { + console.log(isValid); + console.log($scope); + console.log($scope.email); + if (isValid) { + authApi.user.save({ + email: $scope.user.email, + password: $scope.user.password, + }, function(){ + $modalInstance.close('/auth/login'); + }); + } else { + $scope.message = "Il reste toujours des champs invalides"; + } }; $scope.back = function () { $modalInstance.close('/auth/login'); }; + }) + .directive("compareTo", function(){ + return { + require: "ngModel", + scope: { + otherModelValue: "=compareTo" + }, + link: function($scope, element, attributes, ngModel) { + + ngModel.$validators.compareTo = function(modelValue) { + return modelValue == $scope.otherModelValue; + }; + + $scope.$watch("otherModelValue", function() { + ngModel.$validate(); + }); + } + } }); })(); diff -r 4b1294eaec0a -r 76fb2dd72ce4 client/app/auth/login_modal.html --- a/client/app/auth/login_modal.html Thu Jun 11 15:36:07 2015 +0200 +++ b/client/app/auth/login_modal.html Thu Jun 11 15:36:42 2015 +0200 @@ -4,8 +4,14 @@
- -