skapi-js 1.0.31 → 1.0.33
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/user.js +23 -4
- package/package.json +1 -1
package/js/main/skapi.js
CHANGED
package/js/methods/user.js
CHANGED
|
@@ -342,16 +342,35 @@ export async function recoverAccount(redirect = false) {
|
|
|
342
342
|
return 'SUCCESS: Recovery e-mail has been sent.';
|
|
343
343
|
}
|
|
344
344
|
export async function jwtLogin(params) {
|
|
345
|
-
let { hashedPassword } = request.bind(this)("jwt-login", params);
|
|
346
|
-
|
|
345
|
+
let { hashedPassword, username } = request.bind(this)("jwt-login", params);
|
|
346
|
+
try {
|
|
347
|
+
return login.bind(this)({ username: username, password: hashedPassword });
|
|
348
|
+
}
|
|
349
|
+
catch (err) {
|
|
350
|
+
if (err.code === 'INCORRECT_USERNAME_OR_PASSWORD') {
|
|
351
|
+
throw new SkapiError('User has migrated the account. Login with the service username and password.', { code: 'INVALID_REQUEST' });
|
|
352
|
+
}
|
|
353
|
+
}
|
|
347
354
|
}
|
|
348
355
|
export async function login(form) {
|
|
349
356
|
await this.logout();
|
|
350
357
|
let params = validator.Params(form, {
|
|
351
358
|
username: 'string',
|
|
352
|
-
email:
|
|
359
|
+
email: 'string',
|
|
353
360
|
password: (v) => validator.Password(v)
|
|
354
|
-
}, ['
|
|
361
|
+
}, ['password']);
|
|
362
|
+
if (params.email) {
|
|
363
|
+
try {
|
|
364
|
+
validator.Email(params.email);
|
|
365
|
+
}
|
|
366
|
+
catch (err) {
|
|
367
|
+
params.username = params.email;
|
|
368
|
+
delete params.email;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (!params.username && !params.email) {
|
|
372
|
+
throw new SkapiError('Least one of "username" or "email" is required.', { code: 'INVALID_PARAMETER' });
|
|
373
|
+
}
|
|
355
374
|
return authentication.bind(this)().authenticateUser(params.username || params.email, params.password);
|
|
356
375
|
}
|
|
357
376
|
export async function signup(form, option) {
|