X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fhome%2Flogin.tsx;h=828cbb5f8b51cfa66665e546f797c6b0802bce6d;hb=b7ec7ae3110c560968e0cb24a32f1fe9166eec29;hp=6a270899d6c5acf67e3030eba22bde83b4c1e29c;hpb=3ee47d38b8e6cff675bd29b6b081eb0568360ec5;p=lemmy-ui.git diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index 6a27089..828cbb5 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -1,12 +1,13 @@ +import { myAuth, setIsoData } from "@utils/app"; +import { isBrowser } from "@utils/browser"; import { Component, linkEvent } from "inferno"; import { GetSiteResponse, LoginResponse } from "lemmy-js-client"; -import { i18n } from "../../i18next"; -import { UserService } from "../../services"; +import { I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; -import { myAuth, setIsoData, toast, validEmail } from "../../utils"; -import { isBrowser } from "../../utils/browser/is-browser"; +import { toast } from "../../toast"; import { HtmlTags } from "../common/html-tags"; import { Spinner } from "../common/icon"; +import PasswordInput from "../common/password-input"; interface State { loginRes: RequestState; @@ -41,7 +42,9 @@ export class Login extends Component { } get documentTitle(): string { - return `${i18n.t("login")} - ${this.state.siteRes.site_view.site.name}`; + return `${I18NextService.i18n.t("login")} - ${ + this.state.siteRes.site_view.site.name + }`; } get isLemmyMl(): boolean { @@ -50,7 +53,7 @@ export class Login extends Component { render() { return ( -
+
{ return (
-
{i18n.t("login")}
-
+

{I18NextService.i18n.t("login")}

+
{ />
-
- -
- - -
+
+
{this.state.showTotp && ( -
+
{
)} -
+
@@ -170,7 +153,10 @@ export class Login extends Component { case "failed": { if (loginRes.msg === "missing_totp_token") { i.setState({ showTotp: true }); - toast(i18n.t("enter_two_factor_code"), "info"); + toast(I18NextService.i18n.t("enter_two_factor_code"), "info"); + } + if (loginRes.msg === "incorrect_login") { + toast(I18NextService.i18n.t("incorrect_login"), "danger"); } i.setState({ loginRes: { state: "failed", msg: loginRes.msg } }); @@ -178,7 +164,9 @@ export class Login extends Component { } case "success": { - UserService.Instance.login(loginRes.data); + UserService.Instance.login({ + res: loginRes.data, + }); const site = await HttpService.client.getSite({ auth: myAuth(), }); @@ -211,15 +199,4 @@ export class Login extends Component { i.state.form.password = event.target.value; i.setState(i.state); } - - async handlePasswordReset(i: Login, event: any) { - event.preventDefault(); - const email = i.state.form.username_or_email; - if (email) { - const res = await HttpService.client.passwordReset({ email }); - if (res.state == "success") { - toast(i18n.t("reset_password_mail_sent")); - } - } - } }