Skip to content

Commit

Permalink
password encrypt and login password verification
Browse files Browse the repository at this point in the history
  • Loading branch information
Smars-Bin-Hu committed Jul 30, 2024
1 parent f9d526a commit d576d81
Show file tree
Hide file tree
Showing 6 changed files with 559 additions and 13 deletions.
13 changes: 12 additions & 1 deletion controllers/BensonController.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const {
"api-url-config": apiUrls
} = require('../config/config.json');

const {
Utils
} = require('../utils/index')

// access: /login
const getLoginPageAction = (req, res) => {
req.session.username = req.body.username;
Expand Down Expand Up @@ -83,7 +87,14 @@ const postLoginAction = async (req, res) => {
const name = req.body.name;
const pass = req.body.password;
const users = await getUserByUserName(name);
if( users && pass == users.password){

// Smars => 密码解析匹配
const isPasswordMatched = await Utils.PasswordUtils.verifyPassword(pass, users.password);
// console.log(pass); // plain password
// console.log(users.password); // encrypted password
// console.log(isPasswordMatched);

if( users && isPasswordMatched){
console.log('login success.');
req.session.username = name;
req.session.userLoggedIn = true;
Expand Down
Loading

0 comments on commit d576d81

Please sign in to comment.