Skip to content

Commit

Permalink
KEYCLOAK-12875: User w/o pswd can't set pswd in new acct console.
Browse files Browse the repository at this point in the history
  • Loading branch information
ssilvert committed Feb 10, 2020
1 parent 41bf0b7 commit b236cae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ webauthn-display-name=Security Key
webauthn-help-text=Use your security key to log in.
webauthn-passwordless-display-name=Security Key
webauthn-passwordless-help-text=Use your security key for passwordless log in.
basic-authentication=Basic Authentication
basic-auth-help-text=Sign in with username and password.

# Applications page
applicationsPageTitle=Applications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ interface UserCredential {
id: string;
type: string;
userLabel: string;
createdDate: number;
createdDate?: number;
strCreatedDate?: string;
}

Expand All @@ -69,7 +69,6 @@ interface CredentialContainer {
helptext?: string;
createAction?: string;
updateAction?: string;
iconCssClass: string;
removeable: boolean;
userCredentials: UserCredential[];
}
Expand Down Expand Up @@ -185,7 +184,7 @@ class SigningInPage extends React.Component<SigningInPageProps, SigningInPageSta
const type: string = credContainer.type;
const displayName: string = credContainer.displayName;

if (userCredentials.length === 0) {
if (!userCredentials || userCredentials.length === 0) {
const localizedDisplayName = Msg.localize(displayName);
return (
<DataListItem key='no-credentials-list-item' aria-labelledby='no-credentials-list-item'>
Expand All @@ -203,7 +202,7 @@ class SigningInPage extends React.Component<SigningInPageProps, SigningInPageSta

userCredentials.forEach(credential => {
if (!credential.userLabel) credential.userLabel = Msg.localize(credential.type);
credential.strCreatedDate = moment(credential.createdDate).format('LLL');
if (credential.hasOwnProperty('createdDate') && credential.createdDate! > 0) credential.strCreatedDate = moment(credential.createdDate).format('LLL');
});

let updateAIA: AIACommand;
Expand All @@ -216,12 +215,7 @@ class SigningInPage extends React.Component<SigningInPageProps, SigningInPageSta
userCredentials.map(credential => (
<DataListItem id={`${SigningInPage.credElementId(type, credential.id, 'row')}`} key={'credential-list-item-' + credential.id} aria-labelledby={'credential-list-item-' + credential.userLabel}>
<DataListItemRow key={'userCredentialRow-' + credential.id}>
<DataListItemCells
dataListCells={[
<DataListCell id={`${SigningInPage.credElementId(type, credential.id, 'label')}`} key={'userLabel-' + credential.id}>{credential.userLabel}</DataListCell>,
<DataListCell id={`${SigningInPage.credElementId(type, credential.id, 'created-at')}`} key={'created-' + credential.id}><strong><Msg msgKey='credentialCreatedAt'/>: </strong>{credential.strCreatedDate}</DataListCell>,
<DataListCell key={'spacer-' + credential.id}/>
]}/>
<DataListItemCells dataListCells={this.credentialRowCells(credential, type)}/>

<CredentialAction credential={credential}
removeable={removeable}
Expand All @@ -234,8 +228,19 @@ class SigningInPage extends React.Component<SigningInPageProps, SigningInPageSta
</React.Fragment>)
}

private credentialRowCells(credential: UserCredential, type: string): React.ReactNode[] {
const credRowCells: React.ReactNode[] = [];
credRowCells.push(<DataListCell id={`${SigningInPage.credElementId(type, credential.id, 'label')}`} key={'userLabel-' + credential.id}>{credential.userLabel}</DataListCell>);
if (credential.strCreatedDate) {
credRowCells.push(<DataListCell id={`${SigningInPage.credElementId(type, credential.id, 'created-at')}`} key={'created-' + credential.id}><strong><Msg msgKey='credentialCreatedAt'/>: </strong>{credential.strCreatedDate}</DataListCell>);
credRowCells.push(<DataListCell key={'spacer-' + credential.id}/>);
}

return credRowCells;
}

private renderCredTypeTitle(credContainer: CredentialContainer): React.ReactNode {
if (credContainer.category === 'password') return;
if (!credContainer.hasOwnProperty('helptext') && !credContainer.hasOwnProperty('createAction')) return;

let setupAction: AIACommand;
if (credContainer.createAction) {
Expand Down

0 comments on commit b236cae

Please sign in to comment.