You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In implementing Bcrypt to the Mojo.js documented app in the 'growing' guide (see below), the result by bcrypt.compare was to pass any arbituary password for the users in user.js, without errors. Any idea as to why this should happen?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
In implementing Bcrypt to the Mojo.js documented app in the 'growing' guide (see below), the result by bcrypt.compare was to pass any arbituary password for the users in user.js, without errors. Any idea as to why this should happen?
==== controller/example.js
async login (ctx) {
const params = await ctx.params();
const user = params.get('user');
const plainTextPass = params.get('pass');
if (ctx.models.users.check(user, plainTextPass) === false) return await ctx.render();
....
)
==== models/users.js
import * as bcrypt from 'bcryptjs';
export default class Users {
constructor() {
this._data = {
joel: '$2y$10$eOx6Q1yA6syUaSHI2YwEnOTigjFV1ADCCMg0NL9uKDJXTJq3EBbiy',
marcus: 'lulz',
sebastian: 'secr3t'
};
}
check(user, plainTextPass) {
if(this._data[user] === undefined) return false;
const bpasswd = this._data[user];
console.log (bpasswd);
console.log (plainTextPass);
return bcrypt.compare(plainTextPass, bpasswd);
}
}
All reactions