diff --git a/frontend/src/components/auth/EmailAuthComponent.tsx b/frontend/src/components/auth/EmailAuthComponent.tsx deleted file mode 100644 index 58a5a6ed..00000000 --- a/frontend/src/components/auth/EmailAuthComponent.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import { faEnvelope } from "@fortawesome/free-solid-svg-icons"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import TCButton from "components/files/TCButton"; -import { humanReadableError } from "constants/backend"; -import { useAlertQueue } from "hooks/alerts"; -import { useAuthentication } from "hooks/auth"; -import { useRef, useState } from "react"; -import { Col, Form, InputGroup, Overlay, Row, Tooltip } from "react-bootstrap"; -import { CheckCircle } from "react-bootstrap-icons"; -const isValidEmail = (email: string) => { - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); -}; - -const EmailAuthComponent = () => { - const [email, setEmail] = useState(""); - const [isDisabled, setIsDisabled] = useState(false); - const [isSuccess, setIsSuccess] = useState(false); - const { api } = useAuthentication(); - const { addAlert } = useAlertQueue(); - - const target = useRef(null); - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - - setIsDisabled(true); - const login_url = window.location.href; - - try { - await api.post("/users/login", { - email, - login_url, - // 7 days - lifetime: 60 * 60 * 24 * 7, - }); - setIsSuccess(true); - } catch (error) { - addAlert(humanReadableError(error), "error"); - } finally { - setIsDisabled(false); - } - }; - - return isSuccess ? ( - - - - - -

- Verification Email Sent! -

- -
- - - Check your email for a login link. - - - -
- ) : ( -
- - { - setEmail(e.target.value); - }} - value={email} - disabled={isDisabled} - /> - - Sign In - - - 3 && !isValidEmail(email)} - target={target.current} - > - {(props) => Invalid email} - - -
- ); -}; - -export default EmailAuthComponent;