mirror of
https://github.com/plankanban/planka.git
synced 2026-07-15 21:48:11 +03:00
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 wasSubmitting = usePrevious(isSubmitting);
|
||||
|
||||
const [data, handleFieldChange, setData] = useForm(() => ({
|
||||
emailOrUsername: '',
|
||||
password: '',
|
||||
...defaultData,
|
||||
}));
|
||||
const [data, handleFieldChange, setData] = useForm(() => {
|
||||
const initialData = {
|
||||
emailOrUsername: '',
|
||||
password: '',
|
||||
...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 [focusPasswordFieldState, focusPasswordField] = useToggle();
|
||||
|
||||
@@ -24,6 +24,7 @@ module.exports = {
|
||||
oidc: inputs.oidc,
|
||||
version: sails.config.custom.version,
|
||||
};
|
||||
|
||||
if (inputs.user && inputs.user.role === User.Roles.ADMIN) {
|
||||
Object.assign(data, {
|
||||
activeUsersLimit: inputs.internalConfig.activeUsersLimit,
|
||||
@@ -31,6 +32,10 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
|
||||
if (sails.config.custom.demoMode) {
|
||||
data.isDemoMode = true;
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user