summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2020-03-27 23:31:00 -0400
committergumi <git@gumi.ca>2020-03-27 23:31:11 -0400
commitd83e4cb9a5d12230a1d255dcd2c9f167c5cc4751 (patch)
tree590d4cc94f6e0b8e79c7d6bd96d3bfa24b17843e
parent36fa6ec0227a6c2397c2059259b9b2a2a0983c1a (diff)
downloadapi-d83e4cb9a5d12230a1d255dcd2c9f167c5cc4751.tar.gz
api-d83e4cb9a5d12230a1d255dcd2c9f167c5cc4751.tar.bz2
api-d83e4cb9a5d12230a1d255dcd2c9f167c5cc4751.tar.xz
api-d83e4cb9a5d12230a1d255dcd2c9f167c5cc4751.zip
set the vault account id in an account variable
-rw-r--r--src/routers/vault/index.js3
-rw-r--r--src/routers/vault/middlewares/evol/account.js7
-rw-r--r--src/routers/vault/middlewares/legacy/account.js18
-rw-r--r--src/routers/vault/models/evol/char_reg_num_db.js33
-rw-r--r--src/routers/vault/models/evol/global_acc_reg_num_db.js33
5 files changed, 90 insertions, 4 deletions
diff --git a/src/routers/vault/index.js b/src/routers/vault/index.js
index c0bc788..c20e2d2 100644
--- a/src/routers/vault/index.js
+++ b/src/routers/vault/index.js
@@ -26,6 +26,8 @@ const models = {
"login",
"char",
"char_reservation",
+ "global_acc_reg_num_db",
+ "char_reg_num_db",
],
};
@@ -111,7 +113,6 @@ module.exports = exports = class Vault {
await this.sequelize.vault.sync({alter: {drop: false}}); // update SQL tables
- this.api.locals.sequelize = this.sequelize; // for access to sequelize.fn
console.info("Vault: database ready");
return Promise.resolve(true);
diff --git a/src/routers/vault/middlewares/evol/account.js b/src/routers/vault/middlewares/evol/account.js
index a889462..fd6fce9 100644
--- a/src/routers/vault/middlewares/evol/account.js
+++ b/src/routers/vault/middlewares/evol/account.js
@@ -58,6 +58,13 @@ const new_account = async (req, res, next) => {
email: `${session.vault}@vault`, // setting an actual email is pointless
});
+ // store the vault account id as a global account var
+ await req.app.locals.evol.global_acc_reg_num_db.create({
+ accountId: evol_acc.accountId,
+ key: "##VAULT", index: 0,
+ value: session.vault,
+ });
+
req.app.locals.vault.account_log.create({
vaultId: session.vault,
accountType: "EVOL",
diff --git a/src/routers/vault/middlewares/legacy/account.js b/src/routers/vault/middlewares/legacy/account.js
index 50874ed..8a541f5 100644
--- a/src/routers/vault/middlewares/legacy/account.js
+++ b/src/routers/vault/middlewares/legacy/account.js
@@ -225,6 +225,13 @@ const migrate = async (req, res, next) => {
email: `${session.vault}@vault`, // setting an actual email is pointless
});
+ // store the vault account id as a global account var
+ await req.app.locals.evol.global_acc_reg_num_db.create({
+ accountId: evol_acc.accountId,
+ key: "##VAULT", index: 0,
+ value: session.vault,
+ });
+
req.app.locals.vault.migration_log.create({
vaultId: session.vault,
legacyId: legacy.accountId,
@@ -238,8 +245,6 @@ const migrate = async (req, res, next) => {
vaultId: session.vault,
});
- // TODO: set an account variable with the original legacy account id
-
const evol_account = new EvolAccount(evol_acc.accountId, evol_acc.userid);
evol_account.legacyId = legacy.accountId;
evol_account.legacyAccount = legacy;
@@ -277,7 +282,14 @@ const migrate = async (req, res, next) => {
continue;
}
- // TODO: set a variable in the char with the original legacy char id
+ // update the Legacy flags:
+ // for now we're only using a single bit but this can be expanded when
+ // we need it in the future
+ await req.app.locals.evol.char_reg_num_db.create({
+ charId: evol_char.charId,
+ key: "LEGACY", index: 0,
+ value: 0b00000000_00000000_00000000_00000001, // set the Legacy bit
+ });
// remove the name reservation
req.app.locals.evol.char_reservation.destroy({
diff --git a/src/routers/vault/models/evol/char_reg_num_db.js b/src/routers/vault/models/evol/char_reg_num_db.js
new file mode 100644
index 0000000..a38df42
--- /dev/null
+++ b/src/routers/vault/models/evol/char_reg_num_db.js
@@ -0,0 +1,33 @@
+const { DataTypes } = require("sequelize"); // from npm registry
+
+module.exports = {
+ fields: {
+ charId: {
+ type: DataTypes.INTEGER.UNSIGNED,
+ primaryKey: true,
+ allowNull: false,
+ },
+ key: {
+ type: DataTypes.STRING.BINARY,
+ primaryKey: true,
+ allowNull: false,
+ },
+ index: {
+ type: DataTypes.INTEGER.UNSIGNED,
+ primaryKey: true,
+ allowNull: false,
+ defaultValue: 0,
+ },
+ value: {
+ type: DataTypes.INTEGER,
+ allowNull: false,
+ defaultValue: 0,
+ },
+ },
+ options: {
+ engine: "InnoDB",
+ indexes: [
+ { fields: ["char_id"] },
+ ],
+ }
+};
diff --git a/src/routers/vault/models/evol/global_acc_reg_num_db.js b/src/routers/vault/models/evol/global_acc_reg_num_db.js
new file mode 100644
index 0000000..2a77fdd
--- /dev/null
+++ b/src/routers/vault/models/evol/global_acc_reg_num_db.js
@@ -0,0 +1,33 @@
+const { DataTypes } = require("sequelize"); // from npm registry
+
+module.exports = {
+ fields: {
+ accountId: {
+ type: DataTypes.INTEGER.UNSIGNED,
+ primaryKey: true,
+ allowNull: false,
+ },
+ key: {
+ type: DataTypes.STRING.BINARY,
+ primaryKey: true,
+ allowNull: false,
+ },
+ index: {
+ type: DataTypes.INTEGER.UNSIGNED,
+ primaryKey: true,
+ allowNull: false,
+ defaultValue: 0,
+ },
+ value: {
+ type: DataTypes.INTEGER,
+ allowNull: false,
+ defaultValue: 0,
+ },
+ },
+ options: {
+ engine: "InnoDB",
+ indexes: [
+ { fields: ["account_id"] },
+ ],
+ }
+};