2677cd17d8
* new signin/signup * cleanup and password reset * new flow working * cleanup * add 'autoComplete' props * fix prop * try to call email/confirm before resetting password * Dont use password reset token for email confirmation. * add password reset * password manager improvements * update lbryinc * cleanup * slightly improve close button on sign up page * moar fixes * fix password autofil Co-authored-by: Mark Beamer Jr <markbeamerjr@gmail.com>
67 lines
2.1 KiB
JavaScript
67 lines
2.1 KiB
JavaScript
// @flow
|
|
import React, { useState } from 'react';
|
|
import { FormField, Form } from 'component/common/form';
|
|
import Button from 'component/button';
|
|
import Card from 'component/common/card';
|
|
import analytics from 'analytics';
|
|
import Nag from 'component/common/nag';
|
|
import UserPasswordReset from 'component/userPasswordReset';
|
|
|
|
type Props = {
|
|
errorMessage: ?string,
|
|
emailToVerify: ?string,
|
|
doClearEmailEntry: () => void,
|
|
doUserSignIn: (string, ?string) => void,
|
|
onHandleEmailOnly: () => void,
|
|
};
|
|
|
|
export default function UserSignInPassword(props: Props) {
|
|
const { errorMessage, doUserSignIn, emailToVerify, onHandleEmailOnly } = props;
|
|
const [password, setPassword] = useState('');
|
|
const [forgotPassword, setForgotPassword] = React.useState(false);
|
|
|
|
function handleSubmit() {
|
|
if (emailToVerify) {
|
|
doUserSignIn(emailToVerify, password);
|
|
analytics.emailProvidedEvent();
|
|
}
|
|
}
|
|
|
|
function handleChangeToSignIn() {
|
|
onHandleEmailOnly();
|
|
}
|
|
|
|
return (
|
|
<div className="main__sign-in">
|
|
{forgotPassword ? (
|
|
<UserPasswordReset />
|
|
) : (
|
|
<Card
|
|
title={__('Enter Your lbry.tv Password')}
|
|
subtitle={__('Signing in as %email%', { email: emailToVerify })}
|
|
actions={
|
|
<Form onSubmit={handleSubmit} className="section">
|
|
<FormField
|
|
autoFocus
|
|
type="password"
|
|
name="sign_in_password"
|
|
id="password"
|
|
autoComplete="on"
|
|
label={__('Password')}
|
|
value={password}
|
|
onChange={e => setPassword(e.target.value)}
|
|
helper={<Button button="link" label={__('Forgot Password?')} onClick={() => setForgotPassword(true)} />}
|
|
/>
|
|
|
|
<div className="section__actions">
|
|
<Button button="primary" type="submit" label={__('Continue')} disabled={!password} />
|
|
<Button button="link" onClick={handleChangeToSignIn} label={__('Use Magic Link')} />
|
|
</div>
|
|
</Form>
|
|
}
|
|
nag={errorMessage && <Nag type="error" relative message={errorMessage} />}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|