Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Customizable key in the session

Allow customization of the key used to store the email in
the session, defaulting to 'email' if not specified in
options. Option added in README.
  • Loading branch information...
commit bafd35470b7c55f1774c2bf790e00baa37ab86a4 1 parent 3b41a0b
authored January 30, 2012
1  README.md
Source Rendered
@@ -84,6 +84,7 @@ the ones that make sense to them.
84 84
 * audience. The scheme + host + optional port (e.g. `http://berjon.com` or `https://github.com:8001`) for which
85 85
   this authentication is being made. Only override this if you know what you're doing, the client side is a better
86 86
   place to configure this setting (if configured there, it will be used here).
  87
+* sessionKey. The name of the key used to store the email in the session. Defaults to `email`.
87 88
 
88 89
 ## Interface (Client)
89 90
 
8  lib/express-browserid.js
@@ -37,7 +37,7 @@ exports.plugVerifier = function (app, opts) {
37 37
                         var verifierResp = JSON.parse(body)
38 38
                         ,   valid = verifierResp && verifierResp.status === "okay"
39 39
                         ,   email = valid ? verifierResp.email : null;
40  
-                        if (req.session) req.session.email = email;
  40
+                        if (req.session) req.session[getSessionKey(opts)] = email;
41 41
                         // if (valid) console.log("assertion verified successfully for email:", email);
42 42
                         // else console.log("failed to verify assertion:", verifierResp.reason);
43 43
                         if (valid) res.json({ status: "okay", email: email });
@@ -63,7 +63,7 @@ exports.plugLogout = function (app, opts) {
63 63
     opts = opts || {};
64 64
     var route = opts.logoutPath || makePath("/logout", opts);
65 65
     app.all(route, function (req, res) {
66  
-        if (req.session) req.session.email = null;
  66
+        if (req.session) req.session[getSessionKey(opts)] = null;
67 67
         res.json(true);
68 68
     });
69 69
 };
@@ -72,3 +72,7 @@ function makePath (path, opts) {
72 72
     var base = opts.basePath || "/browserid";
73 73
     return base + path;
74 74
 }
  75
+
  76
+function getSessionKey(opts) {
  77
+    return opts.sessionKey || "email";
  78
+}

0 notes on commit bafd354

Please sign in to comment.
Something went wrong with that request. Please try again.