diff --git a/back/methods/vn-user/signIn.js b/back/methods/vn-user/signIn.js
index 36a2fb870..8b14bd12d 100644
--- a/back/methods/vn-user/signIn.js
+++ b/back/methods/vn-user/signIn.js
@@ -43,14 +43,14 @@ module.exports = Self => {
? {email: user}
: {name: user};
const vnUser = await Self.findOne({
- fields: ['active', 'passExpired'],
+ fields: ['id', 'active', 'passExpired'],
where
});
const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
if (vnUser.passExpired && vnUser.passExpired.getTime() <= today.getTime())
- throw new UserError('Pass expired');
+ throw new UserError('Pass expired', 'passExpired', {'id': vnUser.id});
const validCredentials = instance
&& await instance.hasPassword(password);
diff --git a/back/models/vn-user.js b/back/models/vn-user.js
index 710710e4e..47c7fd82d 100644
--- a/back/models/vn-user.js
+++ b/back/models/vn-user.js
@@ -110,13 +110,25 @@ module.exports = function(Self) {
const _setPassword = Self.setPassword;
Self.setPassword = async function(id, newPassword, options, cb) {
- // await Self.rawSql(`CALL account.user_checkPassword(?)`, [newPassword]);
+ // await Self.rawSql(`CALL account.user_setPassword(?, ?)`,
+ // [id, newPassword]);
+ await Self.app.models.Account.syncById(id, newPassword);
await _setPassword.call(this, id, newPassword, options, cb);
+
const user = await Self.findById(id);
await user.updateAttribute('passExpired', null);
return;
};
+ const _changePassword = Self.changePassword;
+ Self.changePassword = async function(id, oldPassword, newPassword, options, cb) {
+ // await Self.rawSql(`CALL account.user_changePassword(?, ?, ?)`,
+ // [id, oldPassword, newPassword]);
+ await Self.app.models.Account.syncById(id, newPassword);
+ await _changePassword.call(this, id, oldPassword, newPassword, options, cb);
+ return;
+ };
+
// FIX THIS
Self.afterRemote('prototype.patchAttributes', async(ctx, instance) => {
if (!ctx.args || !ctx.args.data.email) return;
diff --git a/front/salix/components/change-password/index.html b/front/salix/components/change-password/index.html
index 8d2726d3d..5ea5ced97 100644
--- a/front/salix/components/change-password/index.html
+++ b/front/salix/components/change-password/index.html
@@ -3,7 +3,6 @@
label="Old password"
ng-model="$ctrl.oldPassword"
type="password"
- info="{{'Password requirements' | translate:$ctrl.passRequirements}}"
vn-focus>