forked from Kurounin/ep_auth_session
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (30 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
exports.registerRoute = function(hook_name, args, cb) {
args.app.get("/auth_session", function(req, res) {
var r = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' + "\n";
r += '<html>' + "\n";
r += '<head>' + "\n";
r += '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">' + "\n";
r += '</head>' + "\n";
r += '<body>' + "\n";
r += '<script type="text/javascript">' + "\n";
if (req.query.sessionID) {
r += 'document.cookie = "sessionID=' + encodeURIComponent(req.query.sessionID) + '; path=/; SameSite=None; Secure;";' + "\n";
}
if (req.query.padName) {
var redirectUrl = '/p/';
if (req.query.groupID) {
redirectUrl += encodeURIComponent(req.query.groupID) + '$';
}
redirectUrl += encodeURIComponent(req.query.padName);
if (req.query.lang) {
redirectUrl += "?lang=" + encodeURIComponent(req.query.lang);
}
r += 'document.location.href="' + redirectUrl + '";' + "\n";
}
r += '</script>' + "\n";
r += '</body>' + "\n";
r += '</html>' + "\n";
res.send(r);
});
return cb();
};