Merge pull request #2571 from jryans/auth-disable-custom-urls
Ensure we show registration form when custom URLs are disabled
This commit is contained in:
commit
74d460b4ca
4 changed files with 87 additions and 12 deletions
|
@ -1891,7 +1891,6 @@ export default React.createClass({
|
||||||
sessionId={this.state.register_session_id}
|
sessionId={this.state.register_session_id}
|
||||||
idSid={this.state.register_id_sid}
|
idSid={this.state.register_id_sid}
|
||||||
email={this.props.startingFragmentQueryParams.email}
|
email={this.props.startingFragmentQueryParams.email}
|
||||||
referrer={this.props.startingFragmentQueryParams.referrer}
|
|
||||||
defaultServerDiscoveryError={this.state.defaultServerDiscoveryError}
|
defaultServerDiscoveryError={this.state.defaultServerDiscoveryError}
|
||||||
defaultHsUrl={this.getDefaultHsUrl()}
|
defaultHsUrl={this.getDefaultHsUrl()}
|
||||||
defaultIsUrl={this.getDefaultIsUrl()}
|
defaultIsUrl={this.getDefaultIsUrl()}
|
||||||
|
@ -1899,11 +1898,8 @@ export default React.createClass({
|
||||||
customHsUrl={this.getCurrentHsUrl()}
|
customHsUrl={this.getCurrentHsUrl()}
|
||||||
customIsUrl={this.getCurrentIsUrl()}
|
customIsUrl={this.getCurrentIsUrl()}
|
||||||
makeRegistrationUrl={this._makeRegistrationUrl}
|
makeRegistrationUrl={this._makeRegistrationUrl}
|
||||||
defaultDeviceDisplayName={this.props.defaultDeviceDisplayName}
|
|
||||||
onLoggedIn={this.onRegistered}
|
onLoggedIn={this.onRegistered}
|
||||||
onLoginClick={this.onLoginClick}
|
onLoginClick={this.onLoginClick}
|
||||||
onRegisterClick={this.onRegisterClick}
|
|
||||||
onCancelClick={MatrixClientPeg.get() ? this.onReturnToAppClick : null}
|
|
||||||
onServerConfigChange={this.onServerConfigChange}
|
onServerConfigChange={this.onServerConfigChange}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
@ -560,7 +560,6 @@ module.exports = React.createClass({
|
||||||
const ModularServerConfig = sdk.getComponent("auth.ModularServerConfig");
|
const ModularServerConfig = sdk.getComponent("auth.ModularServerConfig");
|
||||||
const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
|
const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
|
||||||
|
|
||||||
// TODO: May need to adjust the behavior of this config option
|
|
||||||
if (SdkConfig.get()['disable_custom_urls']) {
|
if (SdkConfig.get()['disable_custom_urls']) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,21 +54,17 @@ module.exports = React.createClass({
|
||||||
defaultIsUrl: PropTypes.string,
|
defaultIsUrl: PropTypes.string,
|
||||||
brand: PropTypes.string,
|
brand: PropTypes.string,
|
||||||
email: PropTypes.string,
|
email: PropTypes.string,
|
||||||
referrer: PropTypes.string,
|
|
||||||
|
|
||||||
// An error passed along from higher up explaining that something
|
// An error passed along from higher up explaining that something
|
||||||
// went wrong when finding the defaultHsUrl.
|
// went wrong when finding the defaultHsUrl.
|
||||||
defaultServerDiscoveryError: PropTypes.string,
|
defaultServerDiscoveryError: PropTypes.string,
|
||||||
|
|
||||||
defaultDeviceDisplayName: PropTypes.string,
|
|
||||||
|
|
||||||
// registration shouldn't know or care how login is done.
|
// registration shouldn't know or care how login is done.
|
||||||
onLoginClick: PropTypes.func.isRequired,
|
onLoginClick: PropTypes.func.isRequired,
|
||||||
onCancelClick: PropTypes.func,
|
|
||||||
onServerConfigChange: PropTypes.func.isRequired,
|
onServerConfigChange: PropTypes.func.isRequired,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
const customURLsAllowed = !SdkConfig.get()['disable_custom_urls'];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
busy: false,
|
busy: false,
|
||||||
errorText: null,
|
errorText: null,
|
||||||
|
@ -90,6 +86,8 @@ module.exports = React.createClass({
|
||||||
serverType: null,
|
serverType: null,
|
||||||
hsUrl: this.props.customHsUrl,
|
hsUrl: this.props.customHsUrl,
|
||||||
isUrl: this.props.customIsUrl,
|
isUrl: this.props.customIsUrl,
|
||||||
|
// Phase of the overall registration dialog.
|
||||||
|
phase: customURLsAllowed ? PHASE_SERVER_DETAILS : PHASE_REGISTRATION,
|
||||||
flows: null,
|
flows: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -367,7 +365,6 @@ module.exports = React.createClass({
|
||||||
const ModularServerConfig = sdk.getComponent("auth.ModularServerConfig");
|
const ModularServerConfig = sdk.getComponent("auth.ModularServerConfig");
|
||||||
const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
|
const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
|
||||||
|
|
||||||
// TODO: May need to adjust the behavior of this config option
|
|
||||||
if (SdkConfig.get()['disable_custom_urls']) {
|
if (SdkConfig.get()['disable_custom_urls']) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
83
test/components/structures/auth/Registration-test.js
Normal file
83
test/components/structures/auth/Registration-test.js
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 New Vector Ltd
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import expect from 'expect';
|
||||||
|
import sinon from 'sinon';
|
||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
import ReactTestUtils from 'react-dom/test-utils';
|
||||||
|
import sdk from 'matrix-react-sdk';
|
||||||
|
import SdkConfig from '../../../../src/SdkConfig';
|
||||||
|
import * as TestUtils from '../../../test-utils';
|
||||||
|
|
||||||
|
const Registration = sdk.getComponent(
|
||||||
|
'structures.auth.Registration',
|
||||||
|
);
|
||||||
|
|
||||||
|
describe('Registration', function() {
|
||||||
|
let parentDiv;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
TestUtils.beforeEach(this);
|
||||||
|
parentDiv = document.createElement('div');
|
||||||
|
document.body.appendChild(parentDiv);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
sinon.restore();
|
||||||
|
ReactDOM.unmountComponentAtNode(parentDiv);
|
||||||
|
parentDiv.remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
function render() {
|
||||||
|
return ReactDOM.render(<Registration
|
||||||
|
defaultHsUrl="https://matrix.org"
|
||||||
|
defaultIsUrl="https://vector.im"
|
||||||
|
makeRegistrationUrl={() => {}}
|
||||||
|
onLoggedIn={() => {}}
|
||||||
|
onLoginClick={() => {}}
|
||||||
|
onServerConfigChange={() => {}}
|
||||||
|
/>, parentDiv);
|
||||||
|
}
|
||||||
|
|
||||||
|
it('should show server type selector', function() {
|
||||||
|
const root = render();
|
||||||
|
const selector = ReactTestUtils.findRenderedComponentWithType(
|
||||||
|
root,
|
||||||
|
sdk.getComponent('auth.ServerTypeSelector'),
|
||||||
|
);
|
||||||
|
expect(selector).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show form when custom URLs disabled', function() {
|
||||||
|
sinon.stub(SdkConfig, "get").returns({
|
||||||
|
disable_custom_urls: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const root = render();
|
||||||
|
|
||||||
|
// Set non-empty flows to get past the loading spinner
|
||||||
|
root.setState({
|
||||||
|
flows: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
const form = ReactTestUtils.findRenderedComponentWithType(
|
||||||
|
root,
|
||||||
|
sdk.getComponent('auth.RegistrationForm'),
|
||||||
|
);
|
||||||
|
expect(form).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue