Skip to content

Commit

Permalink
Merge branch 'main' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPlayGamez authored Oct 2, 2024
2 parents bcf5fd1 + a5581df commit c3e5ae9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion file.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class Authenticator {
const originalPush = this.users.push;
this.users.push = (...args) => {
const result = originalPush.apply(this.users, args);
console.log("database changed")
saveUsersToFile(this.users, this.DB_FILE_PATH, this.DB_PASSWORD);
return result;
};
Expand Down
7 changes: 1 addition & 6 deletions mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const mongoose = require('mongoose')
const { nanoid } = require('nanoid');



// Creëer het gebruikersmodel

class Authenticator {
Expand All @@ -20,7 +19,7 @@ class Authenticator {
this.maxLoginAttempts = maxLoginAttempts;

// Verbind met MongoDB
mongoose.connect(MONGODB_CONNECTION_STRING, { useNewUrlParser: true, useUnifiedTopology: true });
mongoose.connect(MONGODB_CONNECTION_STRING);

this.User = mongoose.model('User', userSchema)
}
Expand Down Expand Up @@ -70,13 +69,11 @@ class Authenticator {
if (user.locked) return "User is locked"
const result = await bcrypt.compare(password, user.password);
if (!result) {
console.log(`${user.loginAttempts} >= ${this.maxLoginAttempts}`)

if (user.loginAttempts >= this.maxLoginAttempts) {

this.lockUser(user._id);
} else {
console.log("changing login attempts")
let newAttempts = user.loginAttempts + 1
await this.changeLoginAttempts(user._id, newAttempts);
}
Expand All @@ -101,7 +98,6 @@ class Authenticator {
token: twoFactorCode,
window: 2 // Sta 2 tijdstippen toe voor en na de huidige tijd
});
console.log('Verification result:', verified);
if (!verified) return "Invalid 2FA code";

}
Expand Down Expand Up @@ -154,7 +150,6 @@ class Authenticator {
try {
if (jwt.verify(token, this.JWT_SECRET_KEY, this.JWT_OPTIONS)) {
let jwt_token = jwt.decode(token);
console.log(jwt_token)
let user = await this.getInfoFromUser(jwt_token.id)

if (user.jwt_version == jwt_token.version) {
Expand Down
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seamless-auth",
"version": "3.6.3",
"version": "3.6.5",
"description": "A full fledged authentication system...",
"type": "commonjs",
"main": "memory.js",
Expand All @@ -22,6 +22,14 @@
"start": "node test/test.js",
"test": "npx jest --forceExit *.test.js"
},
"bugs": {
"url": "https://github.com/MattPlayGamez/auth/issues",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "https://github.com/MattPlayGamez/auth"
},
"extensionsToTreatAsEsm": [
".js"
],
Expand All @@ -31,7 +39,6 @@
"dependencies": {
"bcrypt": "^5.0.1",
"dotenv": "^16.4.5",
"fs": "^0.0.2",
"jest": "^29.7.0",
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.7.0",
Expand Down

0 comments on commit c3e5ae9

Please sign in to comment.