fix(admin): sanitize fediverse username (#3437)
* test: add config federation test * fix: santize fediverse username fixes #3424 * refactor: remove commented code * refactor: change username const to usernameValue * refactor: use shorthand property * build: move stories page out of build directory * fix: allow only alphanumeric chars in username * fix: filter out special chars in username Added a regex filter to strip non-alphanumeric chars in username field. * chore: clean unused fields
This commit is contained in:
@@ -112,6 +112,17 @@ const ConfigFederation = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleUsernameChange = ({ fieldName, value }: UpdateArgs) => {
|
||||
handleFieldChange({
|
||||
fieldName,
|
||||
value,
|
||||
});
|
||||
setFormDataValues({
|
||||
...formDataValues,
|
||||
username: value.replace(/\W/g, ''),
|
||||
});
|
||||
};
|
||||
|
||||
const handleEnabledSwitchChange = (value: boolean) => {
|
||||
if (!value) {
|
||||
setFormDataValues({
|
||||
@@ -304,7 +315,7 @@ const ConfigFederation = () => {
|
||||
{...TEXTFIELD_PROPS_FEDERATION_DEFAULT_USER}
|
||||
value={formDataValues.username}
|
||||
initialValue={username}
|
||||
onChange={handleFieldChange}
|
||||
onChange={handleUsernameChange}
|
||||
disabled={!enabled}
|
||||
/>
|
||||
<TextFieldWithSubmit
|
||||
|
||||
Reference in New Issue
Block a user