Improve error handling of API (#4345)
* wip
* wip
* wip
* Update attached_notes.ts
* wip
* Refactor
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Update call.ts
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* ✌️
* Fix
This commit is contained in:
parent
fc52e95ad0
commit
2756f553c6
181 changed files with 2010 additions and 1322 deletions
|
|
@ -15,11 +15,11 @@ export const meta = {
|
|||
}
|
||||
};
|
||||
|
||||
export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
||||
export default define(meta, async (ps, user) => {
|
||||
const _token = ps.token.replace(/\s/g, '');
|
||||
|
||||
if (user.twoFactorTempSecret == null) {
|
||||
return rej('二段階認証の設定が開始されていません');
|
||||
throw new Error('二段階認証の設定が開始されていません');
|
||||
}
|
||||
|
||||
const verified = (speakeasy as any).totp.verify({
|
||||
|
|
@ -29,7 +29,7 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
|||
});
|
||||
|
||||
if (!verified) {
|
||||
return rej('not verified');
|
||||
throw new Error('not verified');
|
||||
}
|
||||
|
||||
await User.update(user._id, {
|
||||
|
|
@ -39,5 +39,5 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => {
|
|||
}
|
||||
});
|
||||
|
||||
res();
|
||||
}));
|
||||
return;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue