skapi-js 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/js/main/skapi.js CHANGED
@@ -22,7 +22,7 @@ export default class Skapi {
22
22
  set user(value) {
23
23
  }
24
24
  constructor(service, owner, options) {
25
- this.version = '1.0.8';
25
+ this.version = '1.0.10';
26
26
  this.session = null;
27
27
  this.connection = null;
28
28
  this.host = 'skapi';
@@ -1007,17 +1007,19 @@ export async function deleteRecords(params) {
1007
1007
  },
1008
1008
  };
1009
1009
  let table_p = validator.Params(params.table || {}, struct, isAdmin ? [] : ['name']);
1010
- if (table_p.subscription === null) {
1011
- delete table_p.subscription;
1012
- }
1013
- else {
1014
- if (!table_p.hasOwnProperty('access_group')) {
1015
- throw new SkapiError('"table.access_group" is required for subscription records.', { code: 'INVALID_PARAMETER' });
1010
+ if (table_p.hasOwnProperty('subscription')) {
1011
+ if (table_p.subscription === null) {
1012
+ delete table_p.subscription;
1016
1013
  }
1017
- else if (table_p.access_group === 0) {
1018
- throw new SkapiError('Public tables does not hold subscription records.', { code: 'INVALID_REQUEST' });
1014
+ else {
1015
+ if (!table_p.hasOwnProperty('access_group')) {
1016
+ throw new SkapiError('"table.access_group" is required for subscription records.', { code: 'INVALID_PARAMETER' });
1017
+ }
1018
+ else if (table_p.access_group === 0) {
1019
+ throw new SkapiError('Public tables does not hold subscription records.', { code: 'INVALID_REQUEST' });
1020
+ }
1021
+ table_p.subscription_group = 1;
1019
1022
  }
1020
- table_p.subscription_group = 1;
1021
1023
  }
1022
1024
  params.table = table_p;
1023
1025
  }
@@ -346,6 +346,7 @@ export async function login(form) {
346
346
  return authentication.bind(this)().authenticateUser(params.username || params.email, params.password);
347
347
  }
348
348
  export async function signup(form, option) {
349
+ let is_admin = await checkAdmin.bind(this)();
349
350
  let params = validator.Params(form || {}, {
350
351
  username: 'string',
351
352
  email: (v) => validator.Email(v),
@@ -362,13 +363,9 @@ export async function signup(form, option) {
362
363
  phone_number_public: ['boolean', () => false],
363
364
  access_group: 'number',
364
365
  misc: 'string'
365
- }, ['email', 'password']);
366
- let is_admin = await checkAdmin.bind(this)();
367
- let admin_creating_account = is_admin && params.service && this.service !== params.service;
368
- if (admin_creating_account) {
369
- params.owner = this.__user.user_id;
370
- }
371
- else {
366
+ }, is_admin ? ['email'] : ['email', 'password']);
367
+ let admin_creating_account = is_admin;
368
+ if (!is_admin) {
372
369
  if (params.access_group) {
373
370
  throw new SkapiError('Only admins can set "access_group" parameter.', { code: 'INVALID_PARAMETER' });
374
371
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skapi-js",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Javascript library for Skapi: Complete JAM Stack, front-end driven serverless backend API service.",
5
5
  "main": "./dist/skapi.module.js",
6
6
  "types": "./js/Main.d.ts",