Fix up login/signing paths and buttons
This commit is contained in:
parent
7cfbf22b27
commit
e131467af9
3 changed files with 26 additions and 5 deletions
|
@ -4,9 +4,9 @@ import { Redirect } from 'react-router-dom';
|
|||
|
||||
import { logIn, verifyCredentials, switchAccount } from 'soapbox/actions/auth';
|
||||
import { fetchInstance } from 'soapbox/actions/instance';
|
||||
import { closeModal } from 'soapbox/actions/modals';
|
||||
import { closeModal, openModal } from 'soapbox/actions/modals';
|
||||
import { BigCard } from 'soapbox/components/big-card';
|
||||
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
||||
import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks';
|
||||
import { getRedirectUrl } from 'soapbox/utils/redirect';
|
||||
import { isStandalone } from 'soapbox/utils/state';
|
||||
|
||||
|
@ -21,6 +21,7 @@ const LoginPage = () => {
|
|||
|
||||
const me = useAppSelector((state) => state.me);
|
||||
const standalone = useAppSelector((state) => isStandalone(state));
|
||||
const { nostrSignup } = useFeatures();
|
||||
|
||||
const token = new URLSearchParams(window.location.search).get('token');
|
||||
|
||||
|
@ -62,6 +63,11 @@ const LoginPage = () => {
|
|||
event.preventDefault();
|
||||
};
|
||||
|
||||
if (nostrSignup) {
|
||||
setTimeout(() => dispatch(openModal('NOSTR_LOGIN')), 100);
|
||||
return <Redirect to='/' />;
|
||||
}
|
||||
|
||||
if (standalone) return <Redirect to='/login/external' />;
|
||||
|
||||
if (shouldRedirect) {
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
import React from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
|
||||
import { openModal } from 'soapbox/actions/modals';
|
||||
import { BigCard } from 'soapbox/components/big-card';
|
||||
import { Text } from 'soapbox/components/ui';
|
||||
import { useInstance, useRegistrationStatus } from 'soapbox/hooks';
|
||||
import { useAppDispatch, useFeatures, useInstance, useRegistrationStatus } from 'soapbox/hooks';
|
||||
|
||||
import RegistrationForm from './registration-form';
|
||||
|
||||
const RegistrationPage: React.FC = () => {
|
||||
const instance = useInstance();
|
||||
const { isOpen } = useRegistrationStatus();
|
||||
const { nostrSignup } = useFeatures();
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
if (nostrSignup) {
|
||||
setTimeout(() => dispatch(openModal('NOSTR_SIGNUP')), 100);
|
||||
return <Redirect to='/' />;
|
||||
}
|
||||
|
||||
if (!isOpen) {
|
||||
return (
|
||||
|
|
|
@ -3,10 +3,11 @@ import { FormattedMessage } from 'react-intl';
|
|||
|
||||
import { openModal } from 'soapbox/actions/modals';
|
||||
import { Button, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useAppSelector, useInstance, useRegistrationStatus } from 'soapbox/hooks';
|
||||
import { useAppDispatch, useAppSelector, useFeatures, useInstance, useRegistrationStatus } from 'soapbox/hooks';
|
||||
|
||||
const SignUpPanel = () => {
|
||||
const instance = useInstance();
|
||||
const { nostrSignup } = useFeatures();
|
||||
const { isOpen } = useRegistrationStatus();
|
||||
const me = useAppSelector((state) => state.me);
|
||||
const dispatch = useAppDispatch();
|
||||
|
@ -25,7 +26,12 @@ const SignUpPanel = () => {
|
|||
</Text>
|
||||
</Stack>
|
||||
|
||||
<Button theme='primary' block onClick={() => dispatch(openModal('NOSTR_SIGNUP'))}>
|
||||
<Button
|
||||
theme='primary'
|
||||
onClick={nostrSignup ? () => dispatch(openModal('NOSTR_SIGNUP')) : undefined}
|
||||
to={nostrSignup ? undefined : '/signup'}
|
||||
block
|
||||
>
|
||||
<FormattedMessage id='account.register' defaultMessage='Sign up' />
|
||||
</Button>
|
||||
</Stack>
|
||||
|
|
Loading…
Reference in a new issue