issue #724 fixed

parent 0bf177f4
...@@ -54,11 +54,12 @@ module.exports = { ...@@ -54,11 +54,12 @@ module.exports = {
if (student) { if (student) {
if (bcrypt.compareSync(req.body.password, student.password)) { if (bcrypt.compareSync(req.body.password, student.password)) {
student.isStudent = true; student.isStudent = true;
student.license = student.license[0]; if (!student.license || !student.license[0] || student.license[0].hasExpired()) {
if (!student.license || student.license.hasExpired()) {
sails.log.error(`Tried to login with non valid license ${req.body.username}`); sails.log.error(`Tried to login with non valid license ${req.body.username}`);
return res.badRequest("Student has an invalid license"); return res.badRequest("Student has an invalid license");
} else } else
student = student.toObject(); // to enable overwrite license field
student.license = student.license[0];
return res.ok({ return res.ok({
user: student, user: student,
token: sailsTokenAuth.issueToken(student, sails.config.jwt.expiresInMinutes), token: sailsTokenAuth.issueToken(student, sails.config.jwt.expiresInMinutes),
......
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