Skip to content

Commit

Permalink
Collect the last authenticated date (#1200)
Browse files Browse the repository at this point in the history
* Collect the last authenticated date

* Useful for validating claims of when a user last was authenticated otherwise we don't currently care to know... could add this to User Stats or Moderation tools if needed/wanted.
* Sessions usually expire and get removed automatically after a period
* Trim comment

Applies to Administration+ duties if needed

* Trim whitespace

Applies to #1200


Auto-merge
  • Loading branch information
Martii authored Oct 24, 2017
1 parent 5c85bfa commit ff570dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,17 @@ exports.callback = function (aReq, aRes, aNext) {
return;
}

// Show a console notice that successfully logged in with development and debug modes
// Show a console notice that successfully logged in
if (isDev || isDbg) {
console.log(colors.green('Logged in'));
}

// Store the user info in the session
aReq.session.user = aUser;

// Save the last date a user sucessfully logged in
aUser.authed = new Date();

// Save the session id on the user model
aUser.sessionId = aReq.sessionID;

Expand Down
1 change: 1 addition & 0 deletions models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var userSchema = new Schema({
// A user can link multiple accounts to their OpenUserJS account
auths: Array,
strategies: Array,
authed: Date, // last logged in

// Store their GitHub username when they import scripts
ghUsername: String,
Expand Down

0 comments on commit ff570dc

Please sign in to comment.