mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Render login if cant find user
This commit is contained in:
parent
c540544e15
commit
feb9eab5ad
2 changed files with 14 additions and 6 deletions
|
@ -1,6 +1,8 @@
|
|||
const logger = require('../../utils/logger.js')
|
||||
const dbtools = require('../../utils/dbtools.js')
|
||||
|
||||
const usersDBName = 'users'
|
||||
|
||||
// TODO: session
|
||||
|
||||
module.exports = function (options) {
|
||||
|
@ -16,15 +18,13 @@ module.exports = function (options) {
|
|||
if (user) {
|
||||
next()
|
||||
} else {
|
||||
res.JSON({
|
||||
success: false,
|
||||
msg: 'You dont have permission to acces this site'
|
||||
})
|
||||
res.render('login')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GetUserByPW (db, password) {
|
||||
// TODO: find user by password
|
||||
return undefined
|
||||
return dbtools.Select(db, usersDBName, {
|
||||
pw: password
|
||||
})[0]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue