updated Ansible scripts to install postfix

parent b1534f95
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
state: present state: present
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Amazon' when: ansible_distribution == 'CentOS' or ansible_distribution == 'Amazon'
- name: Install Postfix (for sending emails)
package:
name: postfix
state: present
- name: Install NPM dependencies - name: Install NPM dependencies
npm: npm:
path: "{{ server_path }}/{{ server_relative_path }}" path: "{{ server_path }}/{{ server_relative_path }}"
......
...@@ -4,6 +4,7 @@ const fs = require('fs'); ...@@ -4,6 +4,7 @@ const fs = require('fs');
const path = require('path'); const path = require('path');
const lodash = require('lodash'); const lodash = require('lodash');
const bcrypt = require('bcrypt-nodejs'); const bcrypt = require('bcrypt-nodejs');
const generatePassword = require('password-generator');
/** /**
* SupervisorController * SupervisorController
...@@ -272,7 +273,7 @@ module.exports = { ...@@ -272,7 +273,7 @@ module.exports = {
var params = req.params.all(); var params = req.params.all();
// Send email confirmation -------------------------------- // Send email confirmation --------------------------------
function sendConfirmationMail(supervisor, cb) { function sendConfirmationMail(supervisor, password, cb) {
var token = sailsTokenAuth.issueToken({ var token = sailsTokenAuth.issueToken({
id_sup: supervisor.id, id_sup: supervisor.id,
...@@ -282,7 +283,11 @@ module.exports = { ...@@ -282,7 +283,11 @@ module.exports = {
var message = sails.__({ var message = sails.__({
phrase: 'signin_mail', phrase: 'signin_mail',
locale: params.lang || 'es-es' locale: params.lang || 'es-es'
}) + 'https://' + req.headers.host + '/sup/activate/' + token; // expires in 1 week },
{
url: 'https://' + req.headers.host + '/sup/activate/' + token,
password: password
});
var subject = sails.__({ var subject = sails.__({
phrase: 'notification_from_pictogram', phrase: 'notification_from_pictogram',
...@@ -303,13 +308,17 @@ module.exports = { ...@@ -303,13 +308,17 @@ module.exports = {
sails.log.debug("Creating supervisor with params " + JSON.stringify(params)); sails.log.debug("Creating supervisor with params " + JSON.stringify(params));
if (!params.password || !params.email ) if (!params.name || !params.surname || !params.email )
return res.badRequest("Invalid params"); return res.badRequest("Invalid params");
// randomly generated memorable password
var password = generatePassword();
var supData = { var supData = {
role: params.role, role: params.role,
name: typeof params.name == 'undefined' ? '' : params.name, name: params.name,
password: params.password, surname: params.surname,
password: password,
email: params.email, email: params.email,
pic: sails.config.pictogram.paths.defaultAvatarFileName, pic: sails.config.pictogram.paths.defaultAvatarFileName,
lang: params.lang || 'es-es', lang: params.lang || 'es-es',
...@@ -321,7 +330,7 @@ module.exports = { ...@@ -321,7 +330,7 @@ module.exports = {
if (!sup) if (!sup)
return res.serverError("Supervisor created but returned null"); return res.serverError("Supervisor created but returned null");
sendConfirmationMail(sup, (err) => { sendConfirmationMail(sup, password, (err) => {
if (err) throw err; if (err) throw err;
return res.ok(); return res.ok();
}); });
......
...@@ -246,6 +246,7 @@ ...@@ -246,6 +246,7 @@
"msg_change_password": "Please enter a new password for your account:", "msg_change_password": "Please enter a new password for your account:",
"msg_request_change_password": "Enter your email to request for a password change. An e-mail will be sent to access password change form.", "msg_request_change_password": "Enter your email to request for a password change. An e-mail will be sent to access password change form.",
"name": "Name", "name": "Name",
"name_invalid": "Invalid name",
"new_img": "New image", "new_img": "New image",
"new_instruction": "New instruction", "new_instruction": "New instruction",
"new_method": "New method", "new_method": "New method",
...@@ -435,6 +436,7 @@ ...@@ -435,6 +436,7 @@
"supervisors": "Supervisors", "supervisors": "Supervisors",
"support": "User support", "support": "User support",
"surname": "Surname", "surname": "Surname",
"surname_invalid": "Invalid surname",
"tag_deleted": "Tag deleted", "tag_deleted": "Tag deleted",
"tape_background": "Tape background", "tape_background": "Tape background",
"template_deleted": "Template deleted", "template_deleted": "Template deleted",
......
...@@ -245,6 +245,7 @@ ...@@ -245,6 +245,7 @@
"msg_change_password": "Por favor, introduzca la nueva clave para su cuenta:", "msg_change_password": "Por favor, introduzca la nueva clave para su cuenta:",
"msg_request_change_password": "Introduzca su correo electrónico para solicitar el cambio de clave. Recibirá un correo con la dirección de acceso al formulario de cambio de clave.", "msg_request_change_password": "Introduzca su correo electrónico para solicitar el cambio de clave. Recibirá un correo con la dirección de acceso al formulario de cambio de clave.",
"name": "Nombre", "name": "Nombre",
"name_invalid": "Nombre inválido",
"new_img": "Nueva imagen", "new_img": "Nueva imagen",
"new_instruction": "Nueva instrucción", "new_instruction": "Nueva instrucción",
"new_method": "Nuevo método", "new_method": "Nuevo método",
...@@ -433,6 +434,7 @@ ...@@ -433,6 +434,7 @@
"support": "Atención al cliente", "support": "Atención al cliente",
"supervisors": "Supervisores", "supervisors": "Supervisores",
"surname": "Apellidos", "surname": "Apellidos",
"surname_invalid": "Apellidos inválidos",
"tag_deleted": "Etiqueta borrada", "tag_deleted": "Etiqueta borrada",
"tape_background": "Fondo de la cinta", "tape_background": "Fondo de la cinta",
"template_deleted": "Plantilla eliminada", "template_deleted": "Plantilla eliminada",
......
...@@ -100,15 +100,12 @@ function LoginCtrl( ...@@ -100,15 +100,12 @@ function LoginCtrl(
var formdata_empty = { var formdata_empty = {
name: '', name: '',
surname: '',
email: '', email: '',
password: '',
password_confirm: '',
lang: '', lang: '',
role: '', role: '',
}; };
$scope.minlength = CONSTANTS.password_minlength;
/* Forms objects */ /* Forms objects */
$scope.forms = {}; $scope.forms = {};
...@@ -142,13 +139,13 @@ $scope.signup = function (formName) { ...@@ -142,13 +139,13 @@ $scope.signup = function (formName) {
return; return;
} }
if ($scope.formdata.password.length < CONSTANTS.password_minlength) { if (typeof $scope.formdata.name == 'undefined' || form.name.$invalid) {
ngToast.danger($translate.instant('password_short', {minlength: CONSTANTS.password_minlength})); ngToast.danger($translate.instant('name_invalid'));
return; return;
} }
if ($scope.formdata.password !== $scope.formdata.password_confirm) { if (typeof $scope.formdata.surname == 'undefined' || form.surname.$invalid) {
ngToast.danger($translate.instant('password_match')); ngToast.danger($translate.instant('surname_invalid'));
return; return;
} }
......
...@@ -154,23 +154,20 @@ ...@@ -154,23 +154,20 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<input type="hidden" ng-model="formdata.role" value="tutor"></input> <input type="hidden" ng-model="formdata.role" value="tutor"></input>
<div class="form-group"> <div class="form-group">
<label translate>email</label> <label translate>name</label>
<div class="form-group"> <div class="form-group">
<input type="email" class="form-control" name="email" placeholder="{{ 'email' | translate }}" ng-model="formdata.email"/> <input type="text" class="form-control" name="name" placeholder="{{ 'name' | translate }}" ng-model="formdata.name" required/>
<span class="color_red text_sm pull-right" ng-show="forms.tutorForm.email.$dirty && forms.tutorForm.email.$invalid" translate>email_invalid</span>
</div> </div>
</div> </div>
<fieldset> <label translate>surname</label>
<label translate>password</label>
<div class="form-group"> <div class="form-group">
<input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}" name="password" required ng-model="formdata.password"/> <input type="text" class="form-control" name="surname" placeholder="{{ 'surname' | translate }}" ng-model="formdata.surname" required/>
<span class="color_red text_sm pull-right" ng-show="formdata.password.length < minlength && forms.tutorForm.password.$dirty && forms.tutorForm.password_confirm.$dirty"> {{ 'password_short' | translate:'{ minlength: minlength }' }}</span>
</div> </div>
<label translate>email</label>
<div class="form-group"> <div class="form-group">
<input type="password" class="form-control" id="signin_password2" placeholder="{{ 'password_confirm' | translate }}" name="password_confirm" required ng-model="formdata.password_confirm"/> <input type="email" class="form-control" name="email" placeholder="{{ 'email' | translate }}" ng-model="formdata.email"/>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm && forms.tutorForm.password.$dirty && forms.tutorForm.password_confirm.$dirty" translate>password_match</span> <span class="color_red text_sm pull-right" ng-show="forms.tutorForm.email.$dirty && forms.tutorForm.email.$invalid" translate>email_invalid</span>
</div> </div>
</fieldset>
<div class="form-group"> <div class="form-group">
<input type="checkbox" ng-model="formdata.disclaimer_accepted"> <input type="checkbox" ng-model="formdata.disclaimer_accepted">
<span translate>disclaimer_accept</span> <span translate>disclaimer_accept</span>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"no_name": "No name", "no_name": "No name",
"no_surname": "No surname", "no_surname": "No surname",
"office_link": "The office/center \"{{ name }}\" with email \"{{ email }}\" has added you as part of its team in Pictogram.", "office_link": "The office/center \"{{ name }}\" with email \"{{ email }}\" has added you as part of its team in Pictogram.",
"signin_mail": "To activate your Pictogram account, click on this link:\n", "signin_mail": "To activate your Pictogram account, first click on this link:\n {{ url }} \nAccess with your email and the following password:\n {{ password }}\nWe recommend to change your password as soon as possible.",
"student_unlinked": "You have lost the link to the student \"{{ name }} {{ surname }}\", with license number \"{{ license }}\".", "student_unlinked": "You have lost the link to the student \"{{ name }} {{ surname }}\", with license number \"{{ license }}\".",
"therapist_office_request": "{{ name }}, with email {{ email }}, is requesting to be linked as therapist to any of your students.", "therapist_office_request": "{{ name }}, with email {{ email }}, is requesting to be linked as therapist to any of your students.",
"tutor_office_request": "{{ name }}, with email {{ email }}, is requesting to be linked as tutor/father/mother to any of your students.", "tutor_office_request": "{{ name }}, with email {{ email }}, is requesting to be linked as tutor/father/mother to any of your students.",
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"no_name": "Sin nombre", "no_name": "Sin nombre",
"no_surname": "Sin apellidos", "no_surname": "Sin apellidos",
"office_link": "El centro/gabinete \"{{ name }}\", con correo electrónico \"{{ email }}\" le ha añadido como parte de su equipo.", "office_link": "El centro/gabinete \"{{ name }}\", con correo electrónico \"{{ email }}\" le ha añadido como parte de su equipo.",
"signin_mail": "Para activar su cuenta en Pictogram, haga click en el siguiente enlace:\n", "signin_mail": "Para activar su cuenta en Pictogram, primero haga click en el siguiente enlace:\n {{ url }} \nAcceda con su correo y la contraseña siguiente:\n {{ password }}\nLe recomendamos modificar la contraseña tan pronto accede al sistema.",
"student_unlinked": "Se ha desvinculado de la cuenta de estudiante \"{{ name }} {{ surname }}\", con número de licencia \"{{ license }}\".", "student_unlinked": "Se ha desvinculado de la cuenta de estudiante \"{{ name }} {{ surname }}\", con número de licencia \"{{ license }}\".",
"therapist_office_request": "El/la terapeuta {{ name }}, con correo electrónico {{ email }}, pide ser asociado a algún estudiante.", "therapist_office_request": "El/la terapeuta {{ name }}, con correo electrónico {{ email }}, pide ser asociado a algún estudiante.",
"tutor_office_request": "El/la tutor/a/padre/madre {{ name }}, con correo electrónico {{ email }}, pide ser asociado a algún estudiante.", "tutor_office_request": "El/la tutor/a/padre/madre {{ name }}, con correo electrónico {{ email }}, pide ser asociado a algún estudiante.",
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"include-all": "~0.1.3", "include-all": "~0.1.3",
"jsonwebtoken": "~0.4.0", "jsonwebtoken": "~0.4.0",
"lodash": "^3.10.1", "lodash": "^3.10.1",
"password-generator": "^2.1.0",
"rc": "~0.5.0", "rc": "~0.5.0",
"sails": "^0.12.3", "sails": "^0.12.3",
"sails-disk": "~0.10.0", "sails-disk": "~0.10.0",
......
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