}
case "success": {
- UserService.Instance.login(loginRes.data);
+ UserService.Instance.login({
+ res: loginRes.data,
+ });
const site = await HttpService.client.getSite({
auth: myAuth(),
});
if (i.state.registerRes.state == "success") {
const data = i.state.registerRes.data;
- UserService.Instance.login(data);
+ UserService.Instance.login({ res: data });
i.setState({ doneRegisteringUser: true });
}
}
// Only log them in if a jwt was set
if (data.jwt) {
- UserService.Instance.login(data);
+ UserService.Instance.login({
+ res: data,
+ });
const site = await HttpService.client.getSite({ auth: myAuth() });
if (i.state.passwordChangeRes.state === "success") {
const data = i.state.passwordChangeRes.data;
- UserService.Instance.login(data);
+ UserService.Instance.login({
+ res: data,
+ });
const site = await HttpService.client.getSite({ auth: myAuth() });
if (site.state === "success") {
...i.state.saveUserSettingsForm,
auth: myAuthRequired(),
});
+
if (saveRes.state === "success") {
- UserService.Instance.login(saveRes.data);
+ UserService.Instance.login({
+ res: saveRes.data,
+ showToast: false,
+ });
toast(I18NextService.i18n.t("saved"));
window.scrollTo(0, 0);
}
auth: myAuthRequired(),
});
if (changePasswordRes.state === "success") {
- UserService.Instance.login(changePasswordRes.data);
+ UserService.Instance.login({
+ res: changePasswordRes.data,
+ showToast: false,
+ });
window.scrollTo(0, 0);
toast(I18NextService.i18n.t("password_changed"));
}
this.#setJwtInfo();
}
- public login(res: LoginResponse) {
+ public login({
+ res,
+ showToast = true,
+ }: {
+ res: LoginResponse;
+ showToast?: boolean;
+ }) {
const expires = new Date();
expires.setDate(expires.getDate() + 365);
if (isBrowser() && res.jwt) {
- toast(I18NextService.i18n.t("logged_in"));
+ showToast && toast(I18NextService.i18n.t("logged_in"));
setAuthCookie(res.jwt);
this.#setJwtInfo();
}