summaryrefslogtreecommitdiff
path: root/src/routers/vault/types/Session.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/routers/vault/types/Session.js')
-rw-r--r--src/routers/vault/types/Session.js78
1 files changed, 64 insertions, 14 deletions
diff --git a/src/routers/vault/types/Session.js b/src/routers/vault/types/Session.js
index 17c77ef..59737b3 100644
--- a/src/routers/vault/types/Session.js
+++ b/src/routers/vault/types/Session.js
@@ -1,34 +1,72 @@
const uuidv4 = require("uuid/v4");
+const Identity = require("./Identity.js");
+const EvolAccount = require("./EvolAccount.js");
+const LegacyAccount = require("./LegacyAccount.js");
/**
* holds a cache of all the user data fetched from SQL
*/
module.exports = class Session {
- /** expiry Date */
+ /**
+ * expiry date
+ */
expires = new Date();
- /** Vault account id */
+ /**
+ * Vault account id
+ * @type {number}
+ */
vault = null;
- /** whether the user logged in */
+ /**
+ * whether the user is properly authenticated
+ */
authenticated = false;
- /** the identity that was used to log in */
+ /**
+ * the identity that was used to log in
+ * @type {Identity}
+ */
identity = null;
- /** the email address of the identity that was used to log in */
+ /**
+ * the email address of the identity that was used to log in
+ * @type {string}
+ */
email;
- /** the secret that is sent after authentication */
+ /**
+ * the secret that is sent once to the client after authentication
+ * @type {string}
+ */
secret;
- /** cache holding all identities */
+ /**
+ * cache holding all identities
+ * @type {Identity[]}
+ */
identities = [];
- /** the main identity of the account */
+ /**
+ * id of the main identity of the account
+ * @type {number}
+ */
primaryIdentity = null;
- /** whether to allow logging in with a non-primary ident */
+ /**
+ * whether to allow logging in with a non-primary ident
+ */
allowNonPrimary = true;
- /** LegacyAccount[] cache holding all legacy game accounts */
+ /**
+ * cache holding all legacy game accounts
+ * @type {LegacyAccount[]}
+ */
legacyAccounts = [];
- /** EvolAccount[] cache holding all evol game accounts */
+ /**
+ * cache holding all evol game accounts
+ * @type {EvolAccount[]}
+ */
gameAccounts = [];
- /** ip that was used to init the session */
+ /**
+ * ip that was used to init the session
+ * @type {string}
+ */
ip;
- /** refuse to authenticate a session with a different IP */
+ /**
+ * refuse to authenticate a session with a different IP
+ */
strictIPCheck = true;
constructor (ip, email) {
@@ -44,7 +82,19 @@ module.exports = class Session {
toJSON (key) {
return {
expires: this.expires,
- identity: this.identity,
+ identity: this.identity.id,
}
}
+
+ /**
+ * serialize the account settings for sending over the network
+ */
+ getAccountData () {
+ return {
+ primaryIdentity: this.primaryIdentity.id,
+ allowNonPrimary: this.allowNonPrimary,
+ strictIPCheck: this.strictIPCheck,
+ vaultId: this.vault,
+ };
+ }
}