Browse Source

Update compat-data

master
Zed A. Shaw 1 month ago
parent
commit
69750846ff
5 changed files with 25 additions and 16 deletions
  1. +1
    -1
      .eslintrc.js
  2. +6
    -5
      lib/models.js
  3. +12
    -0
      migrations/20201030085316_add_initials.js
  4. +4
    -9
      package-lock.json
  5. +2
    -1
      src/routes/api/user/settings.json.js

+ 1
- 1
.eslintrc.js View File

@@ -166,7 +166,7 @@ module.exports = {
"no-path-concat": "error",
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
"no-process-env": "off",
"no-process-exit": "error",
"no-process-exit": "off",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": "error",


+ 6
- 5
lib/models.js View File

@@ -254,8 +254,8 @@ class User extends Model.from_table('users') {
return count;
}

static async register(email, full_name, username, password, tos_agree) {
assert(email && full_name && username && password, "All parameters required.");
static async register(email, full_name, username, password, tos_agree, og_buyer=false) {
assert(email && full_name && username && password, `All parameters required. '${username}' '${full_name}' '${email}'`);

// registration is the first time we also log the user in
const email_hash = await User.hash_email(email); // forces lowercase
@@ -265,9 +265,11 @@ class User extends Model.from_table('users') {
username,
full_name,
email: email_hash,
initials: User.calc_initials(full_name),
active: true,
password: password_hash,
tos_agree,
og_buyer,
avatar_color: randomcolor({luminosity: 'dark'})
});

@@ -275,13 +277,12 @@ class User extends Model.from_table('users') {
}

async init_modules() {
log.debug("Setting up new user", this.username);
await ModuleState.insert({ user_id: this.id, module_id: 0, state: 'active' });
await ExerciseState.insert({ user_id: this.id, module_id: 0, exercise_id: 0, state: 'active' });
}

get initials() {
return this.full_name.split(' ').slice(0, 2).map(i => i[0]).join('');
static calc_initials(full_name) {
return full_name.split(' ').slice(0, 2).map(i => i[0]).join('');
}
}



+ 12
- 0
migrations/20201030085316_add_initials.js View File

@@ -0,0 +1,12 @@

exports.up = (knex) => {
return knex.schema.alterTable('users', table => {
table.string('initials', 2).notNullable().default('__');
});
};

exports.down = (knex) => {
return knex.schema.alterTable('users', table => {
table.dropColumn('initials');
});
};

+ 4
- 9
package-lock.json View File

@@ -13,15 +13,10 @@
}
},
"@babel/compat-data": {
"version": "7.8.6",
"resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.8.6.tgz",
"integrity": "sha512-CurCIKPTkS25Mb8mz267vU95vy+TyUpnctEX2lV33xWNmHAfjruztgiPBbXZRh3xZZy1CYvGx6XfxyTVS+sk7Q==",
"dev": true,
"requires": {
"browserslist": "^4.8.5",
"invariant": "^2.2.4",
"semver": "^5.5.0"
}
"version": "7.12.1",
"resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.12.1.tgz",
"integrity": "sha512-725AQupWJZ8ba0jbKceeFblZTY90McUBWMwHhkFQ9q1zKPJ95GUktljFcgcsIVwRnTnRKlcYzfiNImg5G9m6ZQ==",
"dev": true
},
"@babel/core": {
"version": "7.8.7",


+ 2
- 1
src/routes/api/user/settings.json.js View File

@@ -1,7 +1,7 @@
import * as auth from 'auth';
import assert from 'assert';
import { log } from 'logging';
import { Payment } from '../../../../lib/models';
import { User, Payment } from '../../../../lib/models';
import { stores } from 'sabaton';

/*
@@ -34,6 +34,7 @@ export const post = auth.restricted(
const clean_user = {
full_name: $msg.full_name,
username: $msg.username,
initials: User.calc_initials($msg.full_name)
};

// only add in the email if they give it


Loading…
Cancel
Save