X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fhome%2Flogin.tsx;h=828cbb5f8b51cfa66665e546f797c6b0802bce6d;hb=b7ec7ae3110c560968e0cb24a32f1fe9166eec29;hp=d5dd4d2949b21c16d358a1038d71e8e8ebead1ca;hpb=9166491544dbc7f1c334a1babcfca91d66626824;p=lemmy-ui.git diff --git a/src/shared/components/home/login.tsx b/src/shared/components/home/login.tsx index d5dd4d2..828cbb5 100644 --- a/src/shared/components/home/login.tsx +++ b/src/shared/components/home/login.tsx @@ -1,13 +1,13 @@ import { myAuth, setIsoData } from "@utils/app"; import { isBrowser } from "@utils/browser"; -import { validEmail } from "@utils/helpers"; import { Component, linkEvent } from "inferno"; import { GetSiteResponse, LoginResponse } from "lemmy-js-client"; -import { FirstLoadService, I18NextService, UserService } from "../../services"; +import { I18NextService, UserService } from "../../services"; import { HttpService, RequestState } from "../../services/HttpService"; 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; @@ -32,8 +32,6 @@ export class Login extends Component { constructor(props: any, context: any) { super(props, context); - - FirstLoadService.isFirstLoad; } componentDidMount() { @@ -71,7 +69,7 @@ export class Login extends Component { return (
-
{I18NextService.i18n.t("login")}
+

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

-
- -
- - -
+
+
{this.state.showTotp && (
@@ -177,13 +155,18 @@ export class Login extends Component { i.setState({ showTotp: true }); 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 } }); break; } case "success": { - UserService.Instance.login(loginRes.data); + UserService.Instance.login({ + res: loginRes.data, + }); const site = await HttpService.client.getSite({ auth: myAuth(), }); @@ -216,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(I18NextService.i18n.t("reset_password_mail_sent")); - } - } - } }