1 | "use strict";
|
2 |
|
3 | const Auth = require('./Auth');
|
4 | const audit = require('../helper/audit');
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | class NoAuth extends Auth
|
12 | {
|
13 |
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 | constructor(options = {})
|
20 | {
|
21 | super(options.method || 'nothing', options);
|
22 |
|
23 | |
24 |
|
25 |
|
26 | this.loginUserId = options.loginUserId;
|
27 | }
|
28 |
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 | install(app, prefix)
|
35 | {
|
36 | app.all(`${prefix}/login.json`, (req, res) =>
|
37 | {
|
38 | req.login({
|
39 | id: this.loginUserId
|
40 | }, function (err)
|
41 | {
|
42 | if (err)
|
43 | {
|
44 | res.error(`Login failed: ${err}`, audit.LOGIN_FAILURE);
|
45 | }
|
46 | else
|
47 | {
|
48 | res.success('Logged in', audit.LOGIN);
|
49 | }
|
50 | });
|
51 | });
|
52 | }
|
53 | }
|
54 |
|
55 | module.exports = NoAuth;
|