Add direct link to the Single-Sign On provider if there is only one sign up method available (#26083)
parent
a5768d3ea6
commit
120f5802c0
|
@ -135,7 +135,7 @@ Lint/UselessAssignment:
|
||||||
|
|
||||||
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Max: 143
|
Max: 146
|
||||||
|
|
||||||
# Configuration parameters: CountBlocks, Max.
|
# Configuration parameters: CountBlocks, Max.
|
||||||
Metrics/BlockNesting:
|
Metrics/BlockNesting:
|
||||||
|
|
|
@ -11,7 +11,7 @@ module WebAppControllerConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip_csrf_meta_tags?
|
def skip_csrf_meta_tags?
|
||||||
current_user.nil?
|
!(ENV['OMNIAUTH_ONLY'] == 'true' && Devise.omniauth_providers.length == 1) && current_user.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_app_body_class
|
def set_app_body_class
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { openModal, closeModal } from 'mastodon/actions/modal';
|
||||||
import api from 'mastodon/api';
|
import api from 'mastodon/api';
|
||||||
import Button from 'mastodon/components/button';
|
import Button from 'mastodon/components/button';
|
||||||
import { Icon } from 'mastodon/components/icon';
|
import { Icon } from 'mastodon/components/icon';
|
||||||
import { registrationsOpen } from 'mastodon/initial_state';
|
import { registrationsOpen, sso_redirect } from 'mastodon/initial_state';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
loginPrompt: { id: 'interaction_modal.login.prompt', defaultMessage: 'Domain of your home server, e.g. mastodon.social' },
|
loginPrompt: { id: 'interaction_modal.login.prompt', defaultMessage: 'Domain of your home server, e.g. mastodon.social' },
|
||||||
|
@ -331,8 +331,16 @@ class InteractionModal extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
let signupButton;
|
let signupButton;
|
||||||
|
let signUpOrSignInButton;
|
||||||
|
|
||||||
if (registrationsOpen) {
|
if (sso_redirect) {
|
||||||
|
signUpOrSignInButton = (
|
||||||
|
<a href={sso_redirect} data-method='post' className='button button--block button-tertiary'>
|
||||||
|
<FormattedMessage id='sign_in_banner.sso_redirect' defaultMessage='Login or Register' />
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
if(registrationsOpen) {
|
||||||
signupButton = (
|
signupButton = (
|
||||||
<a href='/auth/sign_up' className='link-button'>
|
<a href='/auth/sign_up' className='link-button'>
|
||||||
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
||||||
|
@ -340,12 +348,22 @@ class InteractionModal extends React.PureComponent {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
signupButton = (
|
signupButton = (
|
||||||
<button className='link-button' onClick={this.handleSignupClick}>
|
<button className='button button--block button-tertiary' onClick={this.handleSignupClick}>
|
||||||
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
<FormattedMessage id='sign_in_banner.create_account' defaultMessage='Create account' />
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signUpOrSignInButton = (
|
||||||
|
<>
|
||||||
|
<a href='/auth/sign_in' className='button button--block'>
|
||||||
|
<FormattedMessage id='sign_in_banner.sign_in' defaultMessage='Login' />
|
||||||
|
</a>
|
||||||
|
{signupButton}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='modal-root__modal interaction-modal'>
|
<div className='modal-root__modal interaction-modal'>
|
||||||
<div className='interaction-modal__lead'>
|
<div className='interaction-modal__lead'>
|
||||||
|
@ -353,6 +371,13 @@ class InteractionModal extends React.PureComponent {
|
||||||
<p>{actionDescription} <strong><FormattedMessage id='interaction_modal.sign_in' defaultMessage='You are not logged in to this server. Where is your account hosted?' /></strong></p>
|
<p>{actionDescription} <strong><FormattedMessage id='interaction_modal.sign_in' defaultMessage='You are not logged in to this server. Where is your account hosted?' /></strong></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className='interaction-modal__choices'>
|
||||||
|
<div className='interaction-modal__choices__choice'>
|
||||||
|
<h3><FormattedMessage id='interaction_modal.on_this_server' defaultMessage='On this server' /></h3>
|
||||||
|
{signUpOrSignInButton}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<IntlLoginForm resourceUrl={url} />
|
<IntlLoginForm resourceUrl={url} />
|
||||||
|
|
||||||
<p className='hint'><FormattedMessage id='interaction_modal.sign_in_hint' defaultMessage="Tip: That's the website where you signed up. If you don't remember, look for the welcome e-mail in your inbox. You can also enter your full username! (e.g. @Mastodon@mastodon.social)" /></p>
|
<p className='hint'><FormattedMessage id='interaction_modal.sign_in_hint' defaultMessage="Tip: That's the website where you signed up. If you don't remember, look for the welcome e-mail in your inbox. You can also enter your full username! (e.g. @Mastodon@mastodon.social)" /></p>
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { fetchServer } from 'mastodon/actions/server';
|
||||||
import { Avatar } from 'mastodon/components/avatar';
|
import { Avatar } from 'mastodon/components/avatar';
|
||||||
import { Icon } from 'mastodon/components/icon';
|
import { Icon } from 'mastodon/components/icon';
|
||||||
import { WordmarkLogo, SymbolLogo } from 'mastodon/components/logo';
|
import { WordmarkLogo, SymbolLogo } from 'mastodon/components/logo';
|
||||||
import { registrationsOpen, me } from 'mastodon/initial_state';
|
import { registrationsOpen, me, sso_redirect } from 'mastodon/initial_state';
|
||||||
|
|
||||||
const Account = connect(state => ({
|
const Account = connect(state => ({
|
||||||
account: state.getIn(['accounts', me]),
|
account: state.getIn(['accounts', me]),
|
||||||
|
@ -73,6 +73,12 @@ class Header extends PureComponent {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if (sso_redirect) {
|
||||||
|
content = (
|
||||||
|
<a href={sso_redirect} data-method='post' className='button button--block button-tertiary'><FormattedMessage id='sign_in_banner.sso_redirect' defaultMessage='Login or Register' /></a>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
let signupButton;
|
let signupButton;
|
||||||
|
|
||||||
if (registrationsOpen) {
|
if (registrationsOpen) {
|
||||||
|
@ -96,6 +102,7 @@ class Header extends PureComponent {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='ui__header'>
|
<div className='ui__header'>
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
|
||||||
import { openModal } from 'mastodon/actions/modal';
|
import { openModal } from 'mastodon/actions/modal';
|
||||||
import { registrationsOpen } from 'mastodon/initial_state';
|
import { registrationsOpen, sso_redirect } from 'mastodon/initial_state';
|
||||||
import { useAppDispatch, useAppSelector } from 'mastodon/store';
|
import { useAppDispatch, useAppSelector } from 'mastodon/store';
|
||||||
|
|
||||||
const SignInBanner = () => {
|
const SignInBanner = () => {
|
||||||
|
@ -19,6 +19,15 @@ const SignInBanner = () => {
|
||||||
|
|
||||||
const signupUrl = useAppSelector((state) => state.getIn(['server', 'server', 'registrations', 'url'], null) || '/auth/sign_up');
|
const signupUrl = useAppSelector((state) => state.getIn(['server', 'server', 'registrations', 'url'], null) || '/auth/sign_up');
|
||||||
|
|
||||||
|
if (sso_redirect) {
|
||||||
|
return (
|
||||||
|
<div className='sign-in-banner'>
|
||||||
|
<p><FormattedMessage id='sign_in_banner.text' defaultMessage='Login to follow profiles or hashtags, favorite, share and reply to posts. You can also interact from your account on a different server.' /></p>
|
||||||
|
<a href={sso_redirect} data-method='post' className='button button--block button-tertiary'><FormattedMessage id='sign_in_banner.sso_redirect' defaultMessage='Login or Register' /></a>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (registrationsOpen) {
|
if (registrationsOpen) {
|
||||||
signupButton = (
|
signupButton = (
|
||||||
<a href={signupUrl} className='button button--block'>
|
<a href={signupUrl} className='button button--block'>
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
* @property {boolean} use_blurhash
|
* @property {boolean} use_blurhash
|
||||||
* @property {boolean=} use_pending_items
|
* @property {boolean=} use_pending_items
|
||||||
* @property {string} version
|
* @property {string} version
|
||||||
|
* @property {string} sso_redirect
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,5 +142,6 @@ export const version = getMeta('version');
|
||||||
export const languages = initialState?.languages;
|
export const languages = initialState?.languages;
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
export const statusPageUrl = getMeta('status_page_url');
|
export const statusPageUrl = getMeta('status_page_url');
|
||||||
|
export const sso_redirect = getMeta('sso_redirect');
|
||||||
|
|
||||||
export default initialState;
|
export default initialState;
|
||||||
|
|
|
@ -598,6 +598,7 @@
|
||||||
"server_banner.server_stats": "Server stats:",
|
"server_banner.server_stats": "Server stats:",
|
||||||
"sign_in_banner.create_account": "Create account",
|
"sign_in_banner.create_account": "Create account",
|
||||||
"sign_in_banner.sign_in": "Login",
|
"sign_in_banner.sign_in": "Login",
|
||||||
|
"sign_in_banner.sso_redirect": "Login or Register",
|
||||||
"sign_in_banner.text": "Login to follow profiles or hashtags, favorite, share and reply to posts. You can also interact from your account on a different server.",
|
"sign_in_banner.text": "Login to follow profiles or hashtags, favorite, share and reply to posts. You can also interact from your account on a different server.",
|
||||||
"status.admin_account": "Open moderation interface for @{name}",
|
"status.admin_account": "Open moderation interface for @{name}",
|
||||||
"status.admin_domain": "Open moderation interface for {domain}",
|
"status.admin_domain": "Open moderation interface for {domain}",
|
||||||
|
|
|
@ -32,6 +32,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||||
single_user_mode: Rails.configuration.x.single_user_mode,
|
single_user_mode: Rails.configuration.x.single_user_mode,
|
||||||
trends_as_landing_page: Setting.trends_as_landing_page,
|
trends_as_landing_page: Setting.trends_as_landing_page,
|
||||||
status_page_url: Setting.status_page_url,
|
status_page_url: Setting.status_page_url,
|
||||||
|
sso_redirect: sso_redirect,
|
||||||
}
|
}
|
||||||
|
|
||||||
if object.current_account
|
if object.current_account
|
||||||
|
@ -108,4 +109,8 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||||
def instance_presenter
|
def instance_presenter
|
||||||
@instance_presenter ||= InstancePresenter.new
|
@instance_presenter ||= InstancePresenter.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sso_redirect
|
||||||
|
"/auth/auth/#{Devise.omniauth_providers[0]}" if ENV['OMNIAUTH_ONLY'] == 'true' && Devise.omniauth_providers.length == 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue