Skip to content

Commit

Permalink
Partial new user propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
Martii committed Jan 14, 2022
1 parent ade240a commit 50b778d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
6 changes: 5 additions & 1 deletion controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ exports.preauth = function (aReq, aRes, aNext) {
// Match cleansed name and this is the casing they have chosen
aReq.body.username = username;

aReq.newUser = true;

// Validate captcha for unknown individual
if (!SITEKEY) {
// Skip captcha for not implemented
Expand Down Expand Up @@ -206,9 +208,11 @@ exports.auth = function (aReq, aRes, aNext) {
aReq.session.redirectTo = '/';
}

// Save the known user on the session and remove
// Save the known statuses of the user on the session and remove
aReq.session.wellKnownUser = aReq.wellKnownUser;
aReq.session.newUser = aReq.newUser;
delete aReq.wellKnownUser;
delete aReq.newUser;

// Save the token from the captcha on the session and remove from body
if (captchaToken) {
Expand Down
8 changes: 4 additions & 4 deletions controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ exports.destroyOne = function (aReq, aRes, aNext) {

destroyOneSession(aReq, authedUser.isAdmin, user, id, function (aErr) {
if (aErr) {
statusCodePage(aReq, aRes, aNext, {
statusCode: aErr.code || 500,
statusMessage: aErr.message
});
// NOTE: Watchpoint
redirectTo.search = (redirectTo.search ? redirectTo.search + '&' : '') +
'curses';
aRes.redirect(redirectTo);
return;
}

Expand Down
5 changes: 3 additions & 2 deletions libs/modifySessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,15 @@ exports.destroyOne = function (aReq, aSkipUserCheck, aUser, aId, aCallback) {
console.log(
'`' + authedUser.name + '`',
'removed a session id of',
'`' + aId + '`',
'`' + aId + '`', 'for `' + aSess.username + '`',
(aSess.passport && aSess.passport.oujsOptions && aSess.passport.oujsOptions.authFrom
? 'authed from `' + aSess.passport.oujsOptions.authFrom + '`'
: '')
);
} else if (authedUser.name !== aUser.name) {
console.log(
'`' + authedUser.name + '`',
'removed a session by',
'removed a session for',
'`' + aUser.name + '`',
(aSess.passport && aSess.passport.oujsOptions && aSess.passport.oujsOptions.authFrom
? 'authed from `' + aSess.passport.oujsOptions.authFrom + '`'
Expand Down Expand Up @@ -331,6 +331,7 @@ exports.findSessionData = function (aQuery, aStore, aOptions, aCallback) {


data.passport.oujsOptions.username = data.username || findMeta(data.user, 'name');
data.passport.oujsOptions.newUser = data.newUser;
data.passport.oujsOptions.sid = aSessionData._id;

// Very simple query filter search check to start.
Expand Down
2 changes: 1 addition & 1 deletion views/includes/session.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="names pull-left">
<span>
{{#user.userPageUrl}}<a href="{{{user.userPageUrl}}}" class="username">{{name}}</a>{{/user.userPageUrl}}
{{^user.userPageUrl}}<span class="username">{{#name}}{{name}}{{/name}}{{^name}}<em>&hellip;</em>{{/name}}</span>{{/user.userPageUrl}}
{{^user.userPageUrl}}<span class="username">{{#passport.oujsOptions.newUser}}<em>{{/passport.oujsOptions.newUser}}{{#name}}{{name}}{{/name}}{{#passport.oujsOptions.newUser}}</em>{{/passport.oujsOptions.newUser}}{{^name}}<em>&hellip;</em>{{/name}}</span>{{/user.userPageUrl}}
<span class="label label-default">{{#user.roleName}}{{user.roleName}}{{/user.roleName}}{{^user.roleName}}<em>&hellip;</em>{{/user.roleName}}</span>
<span class="label label-{{#cookie.secure}}success{{/cookie.secure}}{{^cookie.secure}}warning{{/cookie.secure}}" title="secure">
<i class="fa fa-{{^cookie.secure}}un{{/cookie.secure}}lock"></i>
Expand Down

0 comments on commit 50b778d

Please sign in to comment.