fix(plugin-authentication): autofill in create user

This commit is contained in:
Wroud
2020-09-06 23:45:19 +03:00
parent df42e8e88e
commit 071b53800d
5 changed files with 11 additions and 9 deletions
@@ -103,6 +103,7 @@ export const ServerConfigurationForm = observer(function ServerConfigurationForm
type="password"
name="adminPassword"
state={serverConfig}
autoComplete='new-password'
mod='surface'
required
long
@@ -18,13 +18,15 @@ import { formStyles } from './formStyles';
type Props = {
properties: ObjectPropertyInfo[] | undefined;
credentials: any;
credentials: Record<string, string | number>;
processing: boolean;
prefix?: string;
autofillToken?: string;
className?: string;
}
const RESERVED_KEYWORDS = ['no', 'off', 'new-password'];
export const ObjectPropertyInfoForm = observer(function ObjectPropertyInfoForm({
properties,
credentials,
@@ -51,7 +53,7 @@ export const ObjectPropertyInfoForm = observer(function ObjectPropertyInfoForm({
value={credentials[property.id!]}
onChange={value => handleChange(property.id!, value)}
disabled={processing}
autoComplete={autofillToken === 'off' ? 'off' : `${autofillToken} ${property.id}`}
autoComplete={RESERVED_KEYWORDS.includes(autofillToken) ? autofillToken : `${autofillToken} ${property.id}`}
mod='surface'
>
{property.displayName}
@@ -18,9 +18,7 @@ import { IProperty } from './IProperty';
import { PropertyItem } from './PropertyItem';
import { PROPERTIES_TABLE_STYLES } from './styles';
type PropertiesState = {
[key: string]: string;
}
type PropertiesState = Record<string, string>
type PropertiesTableProps = {
properties: IProperty[];
@@ -210,10 +210,12 @@ export const UserForm = observer(function UserForm({
<InputField
type='password'
name='password'
autoComplete='new-password'
value={controller.credentials.password}
onChange={handlePasswordChange}
disabled={controller.isSaving}
mod='surface'
required
>
{translate('authentication_user_password')}
</InputField>
@@ -226,6 +228,7 @@ export const UserForm = observer(function UserForm({
onChange={handlePasswordRepeatChange}
disabled={controller.isSaving}
mod='surface'
required
>
{translate('authentication_user_password_repeat')}
</InputField>
@@ -180,10 +180,8 @@ export class UserFormController implements IInitializableController, IDestructib
}
private isRoleSelected() {
const rolesState = Array.from(this.credentials.roles.values())
.filter(Boolean);
return rolesState.length > 0;
return Array.from(this.credentials.roles.values())
.some(Boolean);
}
private async updateRoles() {