generated from theBoEffect/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves #370 - includes an update to reset timeout via user operatio…
…n or password reset
- Loading branch information
Bo Motlagh
committed
Oct 25, 2023
1 parent
4c299f7
commit 8dafbaf
Showing
12 changed files
with
211 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import mongoose from 'mongoose'; | ||
import { v4 as uuid } from 'uuid'; | ||
|
||
const loginAttempt = new mongoose.Schema({ | ||
createdAt: { | ||
type: Date, | ||
default: Date.now, | ||
expires: '1h' | ||
}, | ||
authGroup: { | ||
type: String, | ||
required: true | ||
}, | ||
accountId: { | ||
type: String, | ||
required: true | ||
}, | ||
_id: { | ||
type: String, | ||
default: uuid | ||
} | ||
},{ _id: false }); | ||
|
||
export default mongoose.model('login-attempt', loginAttempt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import mongoose from 'mongoose'; | ||
import { v4 as uuid } from 'uuid'; | ||
|
||
const loginTimeout = new mongoose.Schema({ | ||
createdAt: { | ||
type: Date, | ||
default: Date.now | ||
}, | ||
expiresAt: { | ||
type: Date, | ||
required: true, | ||
expires: 0 | ||
}, | ||
authGroup: { | ||
type: String, | ||
required: true | ||
}, | ||
accountId: { | ||
type: String, | ||
required: true | ||
}, | ||
_id: { | ||
type: String, | ||
default: uuid | ||
} | ||
},{ _id: false }); | ||
|
||
loginTimeout.index({ accountId: 1, authGroup: 1}, { unique: true }); | ||
|
||
loginTimeout.virtual('id').get(function(){ | ||
return this._id.toString(); | ||
}); | ||
|
||
loginTimeout.set('toJSON', { | ||
virtuals: true | ||
}); | ||
|
||
loginTimeout.options.toJSON.transform = function (doc, ret, options) { | ||
ret.id = ret._id; | ||
delete ret._id; | ||
}; | ||
|
||
export default mongoose.model('login-timout', loginTimeout); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters