feat: option to pre-fill login credentials automatically (#3021)
Co-authored-by: Dan Ribbens <dan.ribbens@gmail.com>
This commit is contained in:
@@ -144,7 +144,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
||||
setUser(json.user);
|
||||
} else if (json?.token) {
|
||||
setToken(json.token);
|
||||
} else if (autoLogin) {
|
||||
} else if (autoLogin && autoLogin.prefillOnly !== true) {
|
||||
// auto log-in with the provided autoLogin credentials. This is used in dev mode
|
||||
// so you don't have to log in over and over again
|
||||
const autoLoginResult = await requests.post(`${serverURL}${api}/${userSlug}/login`, {
|
||||
|
||||
@@ -26,6 +26,7 @@ const Login: React.FC = () => {
|
||||
admin: {
|
||||
user: userSlug,
|
||||
logoutRoute,
|
||||
autoLogin,
|
||||
components: {
|
||||
beforeLogin,
|
||||
afterLogin,
|
||||
@@ -103,6 +104,10 @@ const Login: React.FC = () => {
|
||||
onSuccess={onSuccess}
|
||||
method="post"
|
||||
action={`${serverURL}${api}/${userSlug}/login`}
|
||||
initialData={{
|
||||
email: autoLogin && autoLogin.prefillOnly ? autoLogin.email : undefined,
|
||||
password: autoLogin && autoLogin.prefillOnly ? autoLogin.password : undefined,
|
||||
}}
|
||||
>
|
||||
<FormLoadingOverlayToggle
|
||||
action="loading"
|
||||
|
||||
Reference in New Issue
Block a user