Don't show login form if using registration bypass

This commit is contained in:
Tanner Collin 2020-08-27 19:39:51 +00:00
parent ece2b41b41
commit 117928a256
2 changed files with 16 additions and 4 deletions

View File

@ -1,5 +1,5 @@
import React, { useState, useEffect, useReducer } from 'react'; import React, { useState, useEffect, useReducer } from 'react';
import { BrowserRouter as Router, Switch, Route, Link, useParams } from 'react-router-dom'; import { BrowserRouter as Router, Switch, Route, Link, useParams, useLocation } from 'react-router-dom';
import moment from 'moment-timezone'; import moment from 'moment-timezone';
import './light.css'; import './light.css';
import { Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Message, Popup, Segment, Table } from 'semantic-ui-react'; import { Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Message, Popup, Segment, Table } from 'semantic-ui-react';
@ -131,6 +131,9 @@ export function Home(props) {
const { user } = props; const { user } = props;
const [stats, setStats] = useState(JSON.parse(localStorage.getItem('stats', 'false'))); const [stats, setStats] = useState(JSON.parse(localStorage.getItem('stats', 'false')));
const [refreshCount, refreshStats] = useReducer(x => x + 1, 0); const [refreshCount, refreshStats] = useReducer(x => x + 1, 0);
const location = useLocation();
const bypass_code = location.hash.replace('#', '');
useEffect(() => { useEffect(() => {
requester('/stats/', 'GET') requester('/stats/', 'GET')
@ -172,9 +175,18 @@ export function Home(props) {
</div> </div>
: :
<div> <div>
<LoginForm {...props} /> {bypass_code ?
<Message warning>
<Message.Header>Outside Registration</Message.Header>
<p>This page allows you to sign up from outside of Protospace.</p>
</Message>
:
<>
<LoginForm {...props} />
<Divider section horizontal>Or</Divider> <Divider section horizontal>Or</Divider>
</>
}
<SignupForm {...props} /> <SignupForm {...props} />
</div> </div>

View File

@ -110,7 +110,7 @@ export function SignupForm(props) {
return ( return (
<Form onSubmit={handleSubmit}> <Form onSubmit={handleSubmit}>
<Header size='medium'>Sign Up from Protospace</Header> <Header size='medium'>Sign Up to Spaceport</Header>
<Form.Group widths='equal'> <Form.Group widths='equal'>
<Form.Input <Form.Input