-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LoginWithEmail to facilitate login with email #10518
Conversation
autoComplete="username" | ||
validate={required()} | ||
/> | ||
<PasswordInput |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice: I changed TextInput for PasswordInput here.
}; | ||
|
||
type FieldValues = Record<string, any>; | ||
export const LoginForm = () => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't use LoginWithEmail here as we also add the "forgot password" link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement!
<LoginForm> | ||
<TextInput | ||
autoFocus | ||
source="email" | ||
label={translate('ra.auth.email', { _: 'Email' })} | ||
autoComplete="email" | ||
type="email" | ||
validate={required()} | ||
/> | ||
<PasswordInput | ||
source="password" | ||
label={translate('ra.auth.password', { _: 'Password' })} | ||
autoComplete="current-password" | ||
validate={required()} | ||
/> | ||
</LoginForm> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we have a LoginFormWithEmail
to make customization even easier (like adding custom content in the simple example)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be too many components (not easy to document). Instead, I documented how to pass custom children.
Problem
To create a custom login form (e.g., to use email/password instead of userrname/password), developers have to copy an enorm amount of code from react-admin.
Solution
Provide a built-in
LoginWithEmail
component:Improve composition of Login components,to allow to easily add custom content.
I also updated the default login form to use a
<PasswordInput>
instead of a<TextInput type="password">
so that we benefit from the "show/hide password" button.How To Test
Additional Checks
master
for a bugfix, ornext
for a feature[ ] The PR includes unit tests (current tests are enough)