3 angular.module('dashboardApp')
4 .controller('SignupCtrl', function($scope, Auth, $state, $window, datepickerPopupConfig) {
8 $scope.$watch('user', function() {
9 $scope.user.name = $scope.user.firstName + ' ' + $scope.user.lastName;
12 $scope.datepickers = {
16 $scope.open = function($event, which, whichnot) {
17 $event.preventDefault();
18 $event.stopPropagation();
20 $scope.datepickers[which]= true;
21 $scope.datepickers[whichnot]= false;
24 $scope.dateOptions = {
30 datepickerPopupConfig.showButtonBar = false;
31 datepickerPopupConfig.appendToBody = false;
33 $scope.minDate = new Date();
34 $scope.minDateFine = new Date();
36 $scope.register = function(form) {
37 $scope.submitted = true;
41 name: $scope.user.name,
42 firstNname: $scope.user.firstName,
43 lastName: $scope.user.lastName,
44 birthDate: $scope.user.birthDate,
45 email: $scope.user.email,
46 password: $scope.user.password
49 // Account created, redirect to home
52 .catch(function(err) {
56 // Update validity of form fields that match the mongoose errors
57 angular.forEach(err.errors, function(error, field) {
58 form[field].$setValidity('mongoose', false);
59 $scope.errors[field] = error.message;
65 $scope.loginOauth = function(provider) {
66 $window.location.href = '/auth/' + provider;