Skip to content
Snippets Groups Projects
Commit 40fa6496 authored by Lloyd Hilaiel's avatar Lloyd Hilaiel
Browse files

fix dbwriter crash on stage_email call. move 'langContext' geration into a...

fix dbwriter crash on stage_email call.  move 'langContext' geration into a central location.  closes #936
parent f8fbc77b
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,16 @@ function checkPassword(pass) {
}
}
function langContext(req) {
return {
lang: req.lang,
locale: req.locale,
gettext: req.gettext,
ngettext: req.ngettext,
format: req.format
};
}
// common functions exported, for use by different api calls
exports.clearAuthenticatedUser = clearAuthenticatedUser;
exports.isAuthed = isAuthed;
......@@ -87,6 +97,7 @@ exports.bcryptPassword = bcryptPassword;
exports.authenticateSession = authenticateSession;
exports.checkPassword = checkPassword;
exports.fowardWritesTo = undefined;
exports.langContext = langContext;
exports.setup = function(options, app) {
const WSAPI_PREFIX = '/wsapi/';
......
......@@ -32,12 +32,8 @@ exports.process = function(req, res) {
try {
// on failure stageEmail may throw
db.stageEmail(req.session.userid, req.body.email, function(secret) {
var langContext = {
lang: req.lang,
locale: req.locale,
gettext: req.gettext,
ngettext: req.ngettext
};
var langContext = wsapi.langContext(req);
// store the email being added in session data
req.session.pendingAddition = secret;
......
......@@ -22,13 +22,8 @@ exports.args = ['email','site'];
exports.i18n = true;
exports.process = function(req, resp) {
var langContext = {
gettext: req.gettext,
lang: req.lang,
locale: req.locale,
ngettext: req.ngettext,
format: req.format
};
var langContext = wsapi.langContext(req);
// staging a user logs you out.
wsapi.clearAuthenticatedUser(req.session);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment