Skip to content

Anti-GDPR1 #1393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ exports.auth = function (aReq, aRes, aNext) {

var authedUser = aReq.session.user;
var consent = aReq.body.consent;
var remember = aReq.body.remember;
var strategy = aReq.body.auth || aReq.params.strategy;
var username = aReq.body.username || aReq.session.username ||
(authedUser ? authedUser.name : null);
Expand Down Expand Up @@ -144,6 +145,12 @@ exports.auth = function (aReq, aRes, aNext) {
aReq.session.username = username;
}

// Store remember in the session so we still have it when they
// get back from authentication
if (!aReq.session.remember) {
aReq.session.remember = remember;
}

User.findOne({ name: { $regex: new RegExp('^' + username + '$', 'i') } },
function (aErr, aUser) {
// WARNING: No error handling at this stage
Expand Down Expand Up @@ -283,6 +290,17 @@ exports.callback = function (aReq, aRes, aNext) {
// Save consent
aUser.consented = true;

// Save remember
if (aReq.session.remember) {
aUser.remember = true;

// Modify expiry to end of browser session
aReq.session.cookie.expires = false;
aReq.session.save();
} else {
aUser.remember = false;
}

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

Expand Down
3 changes: 2 additions & 1 deletion models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ var userSchema = new Schema({
absolute: Number
},
flagged: Boolean,
sessionIds: [String]
sessionIds: [String],
remember: Boolean
});

userSchema.virtual('_since').get(function () {
Expand Down
1 change: 1 addition & 0 deletions views/pages/loginPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ <h3>
</div>
<div class="input-group-addon">
<button class="btn btn-info" type="submit" id="action" class="pull-left">Next <i class="fa fa-sign-in fa-fw"></i></button>
<span class="small" style="white-space: normal;"><input type="checkbox" name="remember" value="true" title="Check this to remember you currently for the browser session. Use sparingly please."></span>
</div>
</div>
</div>
Expand Down