-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthentication.js
70 lines (58 loc) · 1.58 KB
/
authentication.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const Authentication = require("./authenticator");
/**
* Load renderer modules from a given directory
* @param {String} dir
*/
const requireAuthenticationModule = function()
{
try
{
const pAuthMod = require(__dirname + "/plugins/authentication-file.js");
return new pAuthMod();
}
catch (err)
{
}
console.log("No authentication module necessary.")
return new Authentication();
};
const pInstance = requireAuthenticationModule();
module.exports = {
showLoginPage : function(_req, res, _next)
{
let data = pInstance.getLoginPageData();
if (data === "")
res.status(404).send();
else
res.status(200).send(data);
},
signIn : (req, res) => pInstance.signIn(req, res),
isSignedInPlay : function(req, res, next)
{
if (pInstance.isSignedInPlay(req))
next();
else
res.status(403).send(pInstance.getLoginPageData());
},
isSignedInCards : function(req, res, next)
{
if (pInstance.isSignedInCards(req))
next();
else
res.status(403).send(pInstance.getLoginPageData());
},
isSignedInDeckbuilder : function(req, res, next)
{
if (pInstance.isSignedInDeckbuilder(req))
next();
else
res.status(403).send(pInstance.getLoginPageData());
},
isSignedInMap : function(req, res, next)
{
if (pInstance.isSignedInMap(req))
next();
else
res.status(403).send(pInstance.getLoginPageData());
}
};