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/dist/skapi.js +1 -1
- package/dist/skapi.js.map +1 -1
- package/dist/skapi.module.js +1 -1
- package/dist/skapi.module.js.map +1 -1
- package/js/main/skapi.js +1 -1
- package/js/methods/database.js +11 -9
- package/js/methods/user.js +4 -7
- package/package.json +1 -1
package/js/main/skapi.js
CHANGED
package/js/methods/database.js
CHANGED
|
@@ -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
|
|
1011
|
-
|
|
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
|
|
1018
|
-
|
|
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
|
}
|
package/js/methods/user.js
CHANGED
|
@@ -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
|
|
367
|
-
|
|
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