diff options
author | gumi <git@gumi.ca> | 2020-03-15 21:56:57 -0400 |
---|---|---|
committer | gumi <git@gumi.ca> | 2020-03-15 21:56:57 -0400 |
commit | 8a1302edf0506c92bd9a8e83ed7c1e145b246513 (patch) | |
tree | fae4703cb17a829b102c60550acb7cdea0878685 /src/routers/vault/types/Session.js | |
parent | a0a35766911f5354487663b0f148b824ca32ba44 (diff) | |
download | api-8a1302edf0506c92bd9a8e83ed7c1e145b246513.tar.gz api-8a1302edf0506c92bd9a8e83ed7c1e145b246513.tar.bz2 api-8a1302edf0506c92bd9a8e83ed7c1e145b246513.tar.xz api-8a1302edf0506c92bd9a8e83ed7c1e145b246513.zip |
add an Identity type
Diffstat (limited to 'src/routers/vault/types/Session.js')
-rw-r--r-- | src/routers/vault/types/Session.js | 78 |
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, + }; + } } |