mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-23 21:37:03 -04:00
[ReviewDB] update for new api changes; some fixes (#2120)
Co-authored-by: Vendicated <vendicated@riseup.net>
This commit is contained in:
parent
1670733458
commit
e707538b73
8 changed files with 126 additions and 84 deletions
|
@ -61,14 +61,17 @@ export function authorize(callback?: any) {
|
|||
const res = await fetch(url, {
|
||||
headers: new Headers({ Accept: "application/json" })
|
||||
});
|
||||
const { token, success } = await res.json();
|
||||
if (success) {
|
||||
updateAuth({ token });
|
||||
showToast("Successfully logged in!", Toasts.Type.SUCCESS);
|
||||
callback?.();
|
||||
} else if (res.status === 1) {
|
||||
showToast("An Error occurred while logging in.", Toasts.Type.FAILURE);
|
||||
|
||||
if (!res.ok) {
|
||||
const { message } = await res.json();
|
||||
showToast(message || "An error occured while authorizing", Toasts.Type.FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
const { token } = await res.json();
|
||||
updateAuth({ token });
|
||||
showToast("Successfully logged in!", Toasts.Type.SUCCESS);
|
||||
callback?.();
|
||||
} catch (e) {
|
||||
new Logger("ReviewDB").error("Failed to authorize", e);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue