mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
PW is now the primary key, added login/logout route
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
const logger = require('../../utils/logger.js')
|
||||
const dbtools = require('../../utils/dbtools.js')
|
||||
|
||||
// TODO: session
|
||||
|
||||
module.exports = function (options) {
|
||||
const { debugLog, authDB } = options
|
||||
|
||||
@@ -9,8 +11,20 @@ module.exports = function (options) {
|
||||
logger.Log('AUTH: ' + req.url)
|
||||
}
|
||||
|
||||
res.end('NO ACCESS')
|
||||
const user = GetUserByPW(authDB, req.cookies.pw)
|
||||
|
||||
// next()
|
||||
if (user) {
|
||||
next()
|
||||
} else {
|
||||
res.JSON({
|
||||
success: false,
|
||||
msg: 'You dont have permission to acces this site'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GetUserByPW (db, password) {
|
||||
// TODO: find user by password
|
||||
return undefined
|
||||
}
|
||||
|
Reference in New Issue
Block a user