Signup form for tutors ready

parent 71a8171b
......@@ -121,6 +121,7 @@
"edit": "Edit",
"email": "Email address",
"email_confirm": "E-mail address confirmation",
"email_invalid": "Invalid email",
"email_match": "The emails must match",
"email_type": "E-mail address",
"enable_sound_for": "Enable sound for",
......
......@@ -121,6 +121,7 @@
"edit": "Editar",
"email": "Correo electrónico",
"email_confirm": "Repite tu email",
"email_invalid": "El email no es válido",
"email_match": "Los emails deben coincidir",
"email_type": "Introduce tu email",
"enable_sound_for": "Habilitar sonido para",
......
......@@ -113,40 +113,56 @@ function LoginCtrl(
role: '',
};
$scope.minlength = CONSTANTS.password_minlength;
$scope.minlength = CONSTANTS.password_minlength;
$scope.reset = function () {
$scope.formdata = formdata_empty;
};
/* Forms objects */
$scope.forms = {};
$scope.reset = function () {
$scope.formdata = formdata_empty;
};
$scope.reset();
$scope.reset();
// Signup form submit
$scope.signup = function () {
$scope.signup = function (formName) {
var form;
if (formName == 'tutorForm')
form = $scope.forms.tutorForm;
else if (formName == 'therapistForm')
form = $scope.forms.therapistForm;
else
form = $scope.forms.officeForm;
if (typeof $scope.formdata.email == 'undefined' || form.email.$invalid) {
ngToast.danger($translate.instant('email_invalid'));
return;
}
if ($scope.formdata.password.length < CONSTANTS.password_minlength) {
ngToast.danger({ content: $translate.instant('password_short', {minlength: CONSTANTS.password_minlength}) });
ngToast.danger($translate.instant('password_short', {minlength: CONSTANTS.password_minlength}));
return;
}
if (!$scope.formdata.disclaimer_accepted) {
ngToast.danger({ content: $translate.instant('disclaimer_requested') });
if ($scope.formdata.password !== $scope.formdata.password_confirm) {
ngToast.danger($translate.instant('password_match'));
return;
}
if (!$scope.formdata.role) {
ngToast.danger({ content: $translate.instant('case_requested') });
if (!$scope.formdata.disclaimer_accepted) {
ngToast.danger($translate.instant('disclaimer_requested'));
return;
}
if (!$scope.signInForm.$valid)
if (form.$invalid)
return;
$http
.post(config.backend + '/sup', $scope.formdata)
.success(function () {
ngToast.success({ content: $translate.instant('user_created', { name: $scope.formdata.name, surname: $scope.formdata.surname }) });
$scope.reset();
$scope.slide.rightTo('confirmation');
})
.error(function () {
ngToast.danger({ content: $translate.instant('user_exists', {email: $scope.formdata.email}) });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment