summaryrefslogtreecommitdiff
path: root/src/routers/vault/types/Session.js
blob: 9f0cd9526c247d968e6f3d88920f9b38fae18dd7 (plain) (blame)
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
/**
 * holds a cache of all the user data fetched from SQL
 */
module.exports = class Session {
    /** expiry Date */
    expires = new Date();
    /** Vault account id */
    vault = null;
    /** whether the user logged in */
    authenticated = false;
    /** the identity that was used to log in */
    identity = null;
    /** the email address of the identity that was used to log in */
    email;
    /** cache holding all identities */
    identities = [];
    /** the main identity of the account */
    primaryIdentity = null;
    /** whether to allow logging in with a non-primary ident */
    allowNonPrimary = true;
    /** LegacyAccount[] cache holding all legacy game accounts */
    legacyAccounts = [];
    /** EvolAccount[] cache holding all evol game accounts */
    gameAccounts = [];
    /** ip that was used to init the session */
    ip;
    /** refuse to authenticate a session with a different IP */
    strictIPCheck = true;

    constructor (ip, email) {
        this.ip = ip;
        this.email = email.toLowerCase();
    }

    /**
     * serialize for sending over the network
     * @param {*} key
     */
    toJSON (key) {
        return {
            expires: this.expires,
            identity: this.identity,
        }
    }
}