{"size": 1339, "ext": "js", "max_stars_repo_path": "public/modules/users/controllers/signup.client.controller.js", "max_stars_repo_name": "davidnicholai/secudev", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/modules/users/controllers/signup.client.controller.js", "max_issues_repo_name": "davidnicholai/secudev", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/modules/users/controllers/signup.client.controller.js", "max_forks_repo_name": "davidnicholai/secudev", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.7555555556, "max_line_length": 105, "alphanum_fraction": 0.6362957431}
'use strict';

angular.module('users').controller('SignupController', ['$scope', '$http', '$location', 'Authentication',
	function($scope, $http, $location, Authentication) {
		$scope.authentication = Authentication;

		$scope.isAdmin = false;

		if ($scope.authentication.user) {
			if ($scope.authentication.user.roles === 'admin') {
				$scope.isAdmin = true;
			}
		}

		$scope.signup = function() {
      $scope.cannotSignup = true;
			$http.post('/auth/signup', $scope.credentials).success(function(response) {
				// If successful we assign the response to the global user model
				$scope.authentication.user = response;
        $scope.cannotSignup = false;

				// And redirect to the index page
				$location.path('/');
			}).error(function(response) {
				$scope.error = response.message;
        $scope.cannotSignup = false;
			});
		};

		$scope.hasGender = false;

		$scope.checkGender = function() {
			if ($scope.credentials.gender === 'male') {
				$scope.salutations = ['Mr', 'Sir', 'Senior', 'Count'];
				$scope.credentials.salutation = $scope.salutations[0];
				$scope.hasGender = true;
			} else if ($scope.credentials.gender === 'female') {
				$scope.salutations = ['Miss', 'Ms', 'Mrs', 'Madame', 'Seniora'];
				$scope.credentials.salutation = $scope.salutations[0];
				$scope.hasGender = true;
			}
		};

	}
]);