error with admin login fixed

parent 814c8e69
......@@ -2,11 +2,12 @@
* AdminController which manages the administration login and login
* @type {Object}
*/
const bcrypt = require('bcrypt-nodejs');
module.exports = {
// @TODO ¿?¿?
login: function (req, res) {
var bcrypt = require('bcrypt-nodejs');
var email = req.body.email;
var password = req.body.password;
......@@ -15,11 +16,11 @@ module.exports = {
return res.badRequest('No credentials sent');
// Check email
admin = sails.config.pictogram.admins.find((a) => a.email == email);
var admin = sails.config.pictogram.admins.find((a) => a.email == email);
if (typeof admin == 'undefined')
return res.badRequest('User not found');
// if found, check password in encrypted form
// if found, check password in encrypted form
bcrypt.compare(password, admin.password, function (err, match) {
if (err)
return res.serverError('Server error' + err);
......@@ -27,15 +28,15 @@ module.exports = {
return res.unauthorized('Invalid password');
// credentials are valid, return token with max life span
delete admin.password;
var returned_admin = (JSON.parse(JSON.stringify(admin)));
delete returned_admin.password;
return res.ok({
token: sailsTokenAuth.issueToken({'isAdmin': true, 'email': email}, sails.config.jwt.expiresInMinutes),
user: admin
user: returned_admin
});
});
},
// @TODO 357
logout: function (req, res) {
delete req.token;
res.ok('Session closed');
......
......@@ -1168,7 +1168,8 @@ module.exports = {
fs.unlinkSync(path.join(newAvatarDirectory, student.pic));
}
student.pic = newAvatarFileName;
student.pic = newAvatarFileName;
delete student.password;
student.save(function (updateStudentError) {
if (updateStudentError) {
throw updateStudentError;
......
......@@ -2,7 +2,7 @@ var mailerService = require('sails-service-mailer');
module.exports.mailer = function() {
return mailerService('sendmail', {
from: 'no-reply@yottacode.com',
from: 'no-reply@pictogramweb.com',
subject: sails.__('notification_from_pictogram'),
provider: {
path: '/usr/sbin/sendmail'
......
/vagrant/arasaac
\ No newline at end of file
/home/ubuntu/pictogram/sails/arasaac
\ No newline at end of file
......@@ -11,12 +11,12 @@
</div>
<div class="col-xs-4">
<div class="languages-margin text-center text-muted">
Powered by &nbsp; <a href="http://www.yottacode.com"><img src="img/logo_pictogram.png" width="40px" alt="Pictogram" title="Pictogram" /></a>
Powered by &nbsp; <a href="http://www.pictogramweb.com"><img src="img/logo_pictogram.png" width="40px" alt="Pictogram" title="Pictogram" /></a>
</div>
</div>
<div class="col-xs-4">
<div class="languages-margin text-right text-muted">
<a href="mailto:soporte@yottacode.com" translate>support</a> |
<a href="mailto:soporte@pictogramweb.com" translate>support</a> |
<a href='/app/#/disclaimer' target='_blank' translate>disclaimer</a>
</div>
</div>
......
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