Display form with no password field for SSO (#51)
When registering via sso, we don't need to ask for password on registration form. VAN-224
This commit is contained in:
@@ -251,9 +251,12 @@ class RegistrationPage extends React.Component {
|
||||
}
|
||||
});
|
||||
|
||||
this.setState({
|
||||
formValid: emailValid && nameValid && usernameValid && passwordValid && extraFieldsValid,
|
||||
});
|
||||
let formValid = emailValid && nameValid && usernameValid && extraFieldsValid;
|
||||
if (!this.props.thirdPartyAuthContext.currentProvider) {
|
||||
formValid = formValid && passwordValid;
|
||||
}
|
||||
|
||||
this.setState({ formValid });
|
||||
}
|
||||
|
||||
addExtraRequiredFields() {
|
||||
@@ -499,25 +502,27 @@ class RegistrationPage extends React.Component {
|
||||
required
|
||||
/>
|
||||
</ValidationFormGroup>
|
||||
<ValidationFormGroup
|
||||
for="password"
|
||||
invalid={this.state.errors.password !== ''}
|
||||
invalidMessage={this.state.errors.password}
|
||||
>
|
||||
<label htmlFor="password" className="h6 pt-3">
|
||||
{intl.formatMessage(messages['logistration.password.label'])}
|
||||
</label>
|
||||
<Input
|
||||
name="password"
|
||||
id="password"
|
||||
type="password"
|
||||
placeholder=""
|
||||
value={this.state.password}
|
||||
onChange={e => this.handleOnChange(e)}
|
||||
onBlur={e => this.handleOnBlur(e)}
|
||||
required
|
||||
/>
|
||||
</ValidationFormGroup>
|
||||
{!currentProvider && (
|
||||
<ValidationFormGroup
|
||||
for="password"
|
||||
invalid={this.state.errors.password !== ''}
|
||||
invalidMessage={this.state.errors.password}
|
||||
>
|
||||
<label htmlFor="password" className="h6 pt-3">
|
||||
{intl.formatMessage(messages['logistration.password.label'])}
|
||||
</label>
|
||||
<Input
|
||||
name="password"
|
||||
id="password"
|
||||
type="password"
|
||||
placeholder=""
|
||||
value={this.state.password}
|
||||
onChange={e => this.handleOnChange(e)}
|
||||
onBlur={e => this.handleOnBlur(e)}
|
||||
required
|
||||
/>
|
||||
</ValidationFormGroup>
|
||||
)}
|
||||
{ this.addExtraRequiredFields() }
|
||||
<ValidationFormGroup
|
||||
for="optional"
|
||||
|
||||
@@ -19,6 +19,7 @@ describe('./RegistrationPage.js', () => {
|
||||
logistration: {
|
||||
registrationResult: { success: false, redirectUrl: '' },
|
||||
thirdPartyAuthContext: {
|
||||
platformName: 'openedX',
|
||||
currentProvider: null,
|
||||
finishAuthUrl: null,
|
||||
providers: [],
|
||||
@@ -288,6 +289,22 @@ describe('./RegistrationPage.js', () => {
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should display no password field when current provider is present', () => {
|
||||
store = mockStore({
|
||||
...initialState,
|
||||
logistration: {
|
||||
...initialState.logistration,
|
||||
thirdPartyAuthContext: {
|
||||
...initialState.logistration.thirdPartyAuthContext,
|
||||
currentProvider: 'Google',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const tree = renderer.create(reduxWrapper(<IntlRegistrationPage {...props} />)).toJSON();
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should match url after redirection', () => {
|
||||
const dasboardUrl = 'http://test.com/testing-dashboard/';
|
||||
store = mockStore({
|
||||
@@ -403,13 +420,12 @@ describe('./RegistrationPage.js', () => {
|
||||
thirdPartyAuthContext: {
|
||||
...initialState.logistration.thirdPartyAuthContext,
|
||||
currentProvider: 'Apple',
|
||||
platformName: 'edX',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const expectedMessage = 'You\'ve successfully signed into Apple. We just need a little more information before '
|
||||
+ 'you start learning with edX.';
|
||||
+ 'you start learning with openedX.';
|
||||
|
||||
const loginPage = mount(reduxWrapper(<IntlRegistrationPage {...props} />));
|
||||
expect(loginPage.find('#tpa-alert').find('span').text()).toEqual(expectedMessage);
|
||||
|
||||
@@ -1,5 +1,169 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`./RegistrationPage.js should display no password field when current provider is present 1`] = `
|
||||
<div
|
||||
className="register-container mx-auto"
|
||||
>
|
||||
<div
|
||||
className="fade alert-warning mt-n2 alert show"
|
||||
id="tpa-alert"
|
||||
role="alert"
|
||||
>
|
||||
<span>
|
||||
You've successfully signed into Google. We just need a little more information before you start learning with openedX.
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
className="text-left"
|
||||
>
|
||||
<span>
|
||||
Already have an edX account?
|
||||
</span>
|
||||
<a
|
||||
href="/login"
|
||||
>
|
||||
Sign in.
|
||||
</a>
|
||||
</div>
|
||||
<form
|
||||
className="mb-4 mx-auto form-group"
|
||||
>
|
||||
<div
|
||||
className="form-group"
|
||||
>
|
||||
<label
|
||||
className="h6 pt-3"
|
||||
htmlFor="name"
|
||||
>
|
||||
Full Name (required)
|
||||
</label>
|
||||
<input
|
||||
aria-describedby=""
|
||||
className="form-control"
|
||||
id="name"
|
||||
name="name"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
placeholder=""
|
||||
required={true}
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="form-group"
|
||||
>
|
||||
<label
|
||||
className="h6 pt-3"
|
||||
htmlFor="username"
|
||||
>
|
||||
Public Username (required)
|
||||
</label>
|
||||
<input
|
||||
aria-describedby=""
|
||||
className="form-control"
|
||||
id="username"
|
||||
name="username"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
placeholder=""
|
||||
required={true}
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="form-group"
|
||||
>
|
||||
<label
|
||||
className="h6 pt-3"
|
||||
htmlFor="email"
|
||||
>
|
||||
Email (required)
|
||||
</label>
|
||||
<input
|
||||
aria-describedby=""
|
||||
className="form-control"
|
||||
id="email"
|
||||
name="email"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
placeholder=""
|
||||
required={true}
|
||||
type="email"
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="form-group custom-control"
|
||||
>
|
||||
<input
|
||||
aria-describedby=""
|
||||
checked={true}
|
||||
className="form-check-input"
|
||||
id="honor_code"
|
||||
name="honor_code"
|
||||
onChange={[Function]}
|
||||
required={true}
|
||||
type="checkbox"
|
||||
value={true}
|
||||
/>
|
||||
I agree to the Your Platform Name Here
|
||||
<a
|
||||
href="/honor"
|
||||
onClick={[Function]}
|
||||
target="_self"
|
||||
>
|
||||
Honor Code
|
||||
</a>
|
||||
|
||||
<strong
|
||||
className="invalid-feedback"
|
||||
id="honor_code-invalid-feedback"
|
||||
>
|
||||
You must agree to the Your Platform Name Here Honor Code
|
||||
</strong>
|
||||
</div>
|
||||
<div
|
||||
className="form-group custom-control"
|
||||
>
|
||||
<input
|
||||
aria-describedby=""
|
||||
checked={false}
|
||||
className="form-check-input"
|
||||
id="optional"
|
||||
name="optional"
|
||||
onChange={[Function]}
|
||||
required={true}
|
||||
type="checkbox"
|
||||
value={false}
|
||||
/>
|
||||
<p
|
||||
id="additionalFields"
|
||||
onClick={[Function]}
|
||||
role="presentation"
|
||||
>
|
||||
Support education research by providing additional information
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
aria-disabled={false}
|
||||
aria-live="assertive"
|
||||
className="pgn__stateful-btn pgn__stateful-btn-state-default btn-primary submit mt-4 btn btn-primary"
|
||||
disabled={false}
|
||||
onClick={[Function]}
|
||||
type="button"
|
||||
>
|
||||
<span
|
||||
className="d-flex align-items-center justify-content-center"
|
||||
>
|
||||
Create Account
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`./RegistrationPage.js should match TPA provider snapshot 1`] = `
|
||||
<div
|
||||
className="register-container mx-auto"
|
||||
|
||||
Reference in New Issue
Block a user