Add support for custom sign-up URLs (#25014)
This commit is contained in:
parent
dfa5889fc0
commit
ca66e61b93
|
@ -52,7 +52,7 @@ module ApplicationHelper
|
||||||
if closed_registrations? || omniauth_only?
|
if closed_registrations? || omniauth_only?
|
||||||
'https://joinmastodon.org/#getting-started'
|
'https://joinmastodon.org/#getting-started'
|
||||||
else
|
else
|
||||||
new_user_registration_path
|
ENV.fetch('SSO_ACCOUNT_SIGN_UP', new_user_registration_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import { openModal, closeModal } from 'mastodon/actions/modal';
|
||||||
|
|
||||||
const mapStateToProps = (state, { accountId }) => ({
|
const mapStateToProps = (state, { accountId }) => ({
|
||||||
displayNameHtml: state.getIn(['accounts', accountId, 'display_name_html']),
|
displayNameHtml: state.getIn(['accounts', accountId, 'display_name_html']),
|
||||||
|
signupUrl: state.getIn(['server', 'server', 'registrations', 'url'], '/auth/sign_up'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
@ -81,6 +82,7 @@ class InteractionModal extends PureComponent {
|
||||||
url: PropTypes.string,
|
url: PropTypes.string,
|
||||||
type: PropTypes.oneOf(['reply', 'reblog', 'favourite', 'follow']),
|
type: PropTypes.oneOf(['reply', 'reblog', 'favourite', 'follow']),
|
||||||
onSignupClick: PropTypes.func.isRequired,
|
onSignupClick: PropTypes.func.isRequired,
|
||||||
|
signupUrl: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
handleSignupClick = () => {
|
handleSignupClick = () => {
|
||||||
|
@ -88,7 +90,7 @@ class InteractionModal extends PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { url, type, displayNameHtml } = this.props;
|
const { url, type, displayNameHtml, signupUrl } = this.props;
|
||||||
|
|
||||||
const name = <bdi dangerouslySetInnerHTML={{ __html: displayNameHtml }} />;
|
const name = <bdi dangerouslySetInnerHTML={{ __html: displayNameHtml }} />;
|
||||||
|
|
||||||
|
@ -121,7 +123,7 @@ class InteractionModal extends PureComponent {
|
||||||
|
|
||||||
if (registrationsOpen) {
|
if (registrationsOpen) {
|
||||||
signupButton = (
|
signupButton = (
|
||||||
<a href='/auth/sign_up' className='button button--block button-tertiary'>
|
<a href={signupUrl} className='button button--block button-tertiary'>
|
||||||
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,6 +16,10 @@ const Account = connect(state => ({
|
||||||
</Link>
|
</Link>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
const mapStateToProps = (state) => ({
|
||||||
|
signupUrl: state.getIn(['server', 'server', 'registrations', 'url'], '/auth/sign_up'),
|
||||||
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
openClosedRegistrationsModal() {
|
openClosedRegistrationsModal() {
|
||||||
dispatch(openModal('CLOSED_REGISTRATIONS'));
|
dispatch(openModal('CLOSED_REGISTRATIONS'));
|
||||||
|
@ -31,11 +35,12 @@ class Header extends PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
openClosedRegistrationsModal: PropTypes.func,
|
openClosedRegistrationsModal: PropTypes.func,
|
||||||
location: PropTypes.object,
|
location: PropTypes.object,
|
||||||
|
signupUrl: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { signedIn } = this.context.identity;
|
const { signedIn } = this.context.identity;
|
||||||
const { location, openClosedRegistrationsModal } = this.props;
|
const { location, openClosedRegistrationsModal, signupUrl } = this.props;
|
||||||
|
|
||||||
let content;
|
let content;
|
||||||
|
|
||||||
|
@ -51,7 +56,7 @@ class Header extends PureComponent {
|
||||||
|
|
||||||
if (registrationsOpen) {
|
if (registrationsOpen) {
|
||||||
signupButton = (
|
signupButton = (
|
||||||
<a href='/auth/sign_up' className='button'>
|
<a href={signupUrl} className='button'>
|
||||||
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
|
@ -87,4 +92,4 @@ class Header extends PureComponent {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(connect(null, mapDispatchToProps)(Header));
|
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Header));
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useAppDispatch, useAppSelector } from 'mastodon/store';
|
||||||
import { registrationsOpen } from 'mastodon/initial_state';
|
import { registrationsOpen } from 'mastodon/initial_state';
|
||||||
import { openModal } from 'mastodon/actions/modal';
|
import { openModal } from 'mastodon/actions/modal';
|
||||||
|
|
||||||
const SignInBanner = () => {
|
const SignInBanner = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const openClosedRegistrationsModal = useCallback(
|
const openClosedRegistrationsModal = useCallback(
|
||||||
() => dispatch(openModal('CLOSED_REGISTRATIONS')),
|
() => dispatch(openModal('CLOSED_REGISTRATIONS')),
|
||||||
|
@ -14,9 +14,11 @@ const SignInBanner = () => {
|
||||||
|
|
||||||
let signupButton;
|
let signupButton;
|
||||||
|
|
||||||
|
const signupUrl = useAppSelector((state) => state.getIn(['server', 'server', 'registrations', 'url'], '/auth/sign_up'));
|
||||||
|
|
||||||
if (registrationsOpen) {
|
if (registrationsOpen) {
|
||||||
signupButton = (
|
signupButton = (
|
||||||
<a href='/auth/sign_up' className='button button--block'>
|
<a href={signupUrl} className='button button--block'>
|
||||||
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
|
|
|
@ -85,6 +85,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||||
enabled: registrations_enabled?,
|
enabled: registrations_enabled?,
|
||||||
approval_required: Setting.registrations_mode == 'approved',
|
approval_required: Setting.registrations_mode == 'approved',
|
||||||
message: registrations_enabled? ? nil : registrations_message,
|
message: registrations_enabled? ? nil : registrations_message,
|
||||||
|
url: ENV.fetch('SSO_ACCOUNT_SIGN_UP', nil),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue