Skip to content

Commit

Permalink
fix(account-settings): disable fields + show info for OpenIDConnect
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikThePendric committed Feb 23, 2021
1 parent 70b251f commit 805b4fa
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions i18n/module/i18n_module_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ login=Login
never=Never
invalid_date=Invalid date
user_profile=User profile
open_id_connect_account_notification=This account is using OpenID Connect. Updating user account settings needs to be done at the OpenID Connect provider.
28 changes: 26 additions & 2 deletions src/account/AccountEditor.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import appActions from '../app.actions';
import accountActions from './account.actions';
import isValidPassword from './isValidPassword';

const styles= {
notification: {
border: '1px solid #bdbdbd',
backgroundColor: '#e5e5e5',
padding: 12,
}
}


class AccountEditor extends Component {
constructor (props) {
Expand Down Expand Up @@ -66,6 +74,7 @@ class AccountEditor extends Component {
}

render() {
const usesOpenIdConnect = this.context.d2.currentUser.externalAuth
const fields = [
{
name: 'username',
Expand All @@ -87,6 +96,7 @@ class AccountEditor extends Component {
style: { width: '100%' },
changeEvent: 'onBlur',
autoComplete: 'new-password',
disabled: usesOpenIdConnect,
},
validators: [{
validator: this.isNotEmpty,
Expand All @@ -103,6 +113,7 @@ class AccountEditor extends Component {
style: { width: '100%' },
changeEvent: 'onBlur',
autoComplete: 'new-password',
disabled: usesOpenIdConnect,
},
validators: [{
validator: isValidPassword,
Expand All @@ -119,6 +130,7 @@ class AccountEditor extends Component {
style: { width: '100%' },
changeEvent: 'onBlur',
autoComplete: 'new-password',
disabled: usesOpenIdConnect,
},
validators: [{
validator: this.isSamePassword,
Expand All @@ -133,6 +145,7 @@ class AccountEditor extends Component {
onClick: this.openTwoFactorDialog,
style: { marginTop: '20px' },
secondary: false,
disabled: usesOpenIdConnect,
},
},
{
Expand All @@ -143,16 +156,27 @@ class AccountEditor extends Component {
onClick: this.updatePassword,
style: { marginTop: '20px' },
secondary: true,
disabled: usesOpenIdConnect,
},
},
];

const setRef = (r) => { this.formBuilder = r; };

return <FormBuilder
return (
<>
{usesOpenIdConnect && (
<div style={styles.notification}>
{this.context.d2.i18n.getTranslation('open_id_connect_account_notification')}
</div>
)}
<FormBuilder
fields={fields}
onUpdateField={this.updateState}
ref={setRef}
/>;
/>
</>
);
}
}
AccountEditor.propTypes = { username: PropTypes.string.isRequired };
Expand Down

0 comments on commit 805b4fa

Please sign in to comment.