blob: 17c77efe911be95281eb9ff6492194a010545210 (
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
46
47
48
49
50
|
const uuidv4 = require("uuid/v4");
/**
* 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;
/** the secret that is sent after authentication */
secret;
/** 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();
this.secret = uuidv4();
}
/**
* serialize for sending over the network
* @param {*} key
*/
toJSON (key) {
return {
expires: this.expires,
identity: this.identity,
}
}
}
|