fix: 一部のエラーがちゃんと出るように
This commit is contained in:
parent
46c94518e7
commit
88325d8e5e
|
@ -163,16 +163,6 @@ async function onUsernameSubmitted(username: string) {
|
||||||
username,
|
username,
|
||||||
}).catch(() => null);
|
}).catch(() => null);
|
||||||
|
|
||||||
if (userInfo.value == null) {
|
|
||||||
await os.alert({
|
|
||||||
type: 'error',
|
|
||||||
title: i18n.ts.noSuchUser,
|
|
||||||
text: i18n.ts.signinFailed,
|
|
||||||
});
|
|
||||||
waiting.value = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await tryLogin({
|
await tryLogin({
|
||||||
username,
|
username,
|
||||||
});
|
});
|
||||||
|
@ -223,15 +213,19 @@ async function onTotpSubmitted(token: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function tryLogin(req: Partial<Misskey.entities.SigninRequest>): Promise<Misskey.entities.SigninResponse> {
|
async function tryLogin(req: Partial<Misskey.entities.SigninRequest>): Promise<Misskey.entities.SigninResponse> {
|
||||||
if (userInfo.value == null) {
|
|
||||||
throw new Error('No such user');
|
|
||||||
}
|
|
||||||
|
|
||||||
const _req = {
|
const _req = {
|
||||||
username: userInfo.value.username,
|
username: req.username ?? userInfo.value?.username,
|
||||||
...req,
|
...req,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function assertIsSigninRequest(x: Partial<Misskey.entities.SigninRequest>): x is Misskey.entities.SigninRequest {
|
||||||
|
return x.username != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!assertIsSigninRequest(_req)) {
|
||||||
|
throw new Error('Invalid request');
|
||||||
|
}
|
||||||
|
|
||||||
return await misskeyApi('signin', _req).then(async (res) => {
|
return await misskeyApi('signin', _req).then(async (res) => {
|
||||||
emit('login', res);
|
emit('login', res);
|
||||||
await onLoginSucceeded(res);
|
await onLoginSucceeded(res);
|
||||||
|
|
Loading…
Reference in New Issue