feat: Add ability to pre-fill login credentials in demo mode
This commit is contained in:
@@ -102,11 +102,27 @@ const Content = React.memo(() => {
|
|||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const wasSubmitting = usePrevious(isSubmitting);
|
const wasSubmitting = usePrevious(isSubmitting);
|
||||||
|
|
||||||
const [data, handleFieldChange, setData] = useForm(() => ({
|
const [data, handleFieldChange, setData] = useForm(() => {
|
||||||
|
const initialData = {
|
||||||
emailOrUsername: '',
|
emailOrUsername: '',
|
||||||
password: '',
|
password: '',
|
||||||
...defaultData,
|
...defaultData,
|
||||||
}));
|
};
|
||||||
|
|
||||||
|
if (bootstrap.isDemoMode) {
|
||||||
|
const params = new URLSearchParams(window.location.hash.slice(1));
|
||||||
|
|
||||||
|
Object.keys(initialData).forEach((fieldName) => {
|
||||||
|
const value = params.get(fieldName);
|
||||||
|
|
||||||
|
if (value !== null) {
|
||||||
|
initialData[fieldName] = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return initialData;
|
||||||
|
});
|
||||||
|
|
||||||
const message = useMemo(() => createMessage(error), [error]);
|
const message = useMemo(() => createMessage(error), [error]);
|
||||||
const [focusPasswordFieldState, focusPasswordField] = useToggle();
|
const [focusPasswordFieldState, focusPasswordField] = useToggle();
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ module.exports = {
|
|||||||
oidc: inputs.oidc,
|
oidc: inputs.oidc,
|
||||||
version: sails.config.custom.version,
|
version: sails.config.custom.version,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (inputs.user && inputs.user.role === User.Roles.ADMIN) {
|
if (inputs.user && inputs.user.role === User.Roles.ADMIN) {
|
||||||
Object.assign(data, {
|
Object.assign(data, {
|
||||||
activeUsersLimit: inputs.internalConfig.activeUsersLimit,
|
activeUsersLimit: inputs.internalConfig.activeUsersLimit,
|
||||||
@@ -31,6 +32,10 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sails.config.custom.demoMode) {
|
||||||
|
data.isDemoMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user