login funktion angepasst
This commit is contained in:
parent
6e1deb2612
commit
1670b943f7
10
package-lock.json
generated
10
package-lock.json
generated
@ -9,6 +9,7 @@
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"app-root-path": "^3.1.0",
|
||||
"dotenv": "^16.4.7",
|
||||
"express": "^4.21.2",
|
||||
"express-session": "^1.18.1",
|
||||
@ -29,6 +30,15 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/app-root-path": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-3.1.0.tgz",
|
||||
"integrity": "sha512-biN3PwB2gUtjaYy/isrU3aNWI5w+fAfvHkSvCKeQGxhmYpwKFUxudR3Yya+KqVRHBmEDYh+/lTozYCFbmzX4nA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/array-flatten": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
"license": "ISC",
|
||||
"description": "Webshop Autohändler",
|
||||
"dependencies": {
|
||||
"app-root-path": "^3.1.0",
|
||||
"dotenv": "^16.4.7",
|
||||
"express": "^4.21.2",
|
||||
"express-session": "^1.18.1",
|
||||
|
||||
@ -5,8 +5,23 @@ let userInput = "test1"
|
||||
let appRoot = require('app-root-path')
|
||||
let dbConnect = require(appRoot + '/scripts/modules/db-connect.js')
|
||||
|
||||
dbConnect.query("SELECT * FROM webshop.user WHERE email = " + "'" + userInput + "'", function (err, result) {
|
||||
if (err) throw err
|
||||
console.log(result)
|
||||
dbConnect.query("SELECT is_active, name, passwd FROM webshop.user WHERE email = " + "'" + userInput + "'", async (err, result) => {
|
||||
if (err)
|
||||
console.log(err)
|
||||
|
||||
if(result.length > 0){
|
||||
// tell user "email is already in use"
|
||||
} else if (passwd !== passwd_confirm){
|
||||
// tell user "passwords do not match"
|
||||
}
|
||||
let hashedPasswd = await bcrypt.hash(password, 8)
|
||||
|
||||
dbConnect.query('INSERT INTO user SET?', {name: name, email: email, passwd: hashedPasswd}, (err, res) => {
|
||||
if(err)
|
||||
console.log(err)
|
||||
else{
|
||||
// tell user "user registered"
|
||||
}
|
||||
})
|
||||
})
|
||||
dbConnect.end()
|
||||
Loading…
x
Reference in New Issue
Block a user