mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-13 17:27:37 -05:00
actually redirects to terms
This commit is contained in:
@@ -8,7 +8,7 @@ import { useNavigate, useLocation } from 'react-router-dom';
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const Restricted = ({ children }) => {
|
const Restricted = ({ children }) => {
|
||||||
const { authenticated, hasAuthenticated,terms } = useSelector((state) => state.user);
|
const { authenticated, hasAuthenticated, terms } = useSelector((state) => state.user);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -22,8 +22,9 @@ const Restricted = ({ children }) => {
|
|||||||
if (authenticated) {
|
if (authenticated) {
|
||||||
if ((pathname != "/terms") && (terms != 1.1)) {
|
if ((pathname != "/terms") && (terms != 1.1)) {
|
||||||
navigate("/terms")
|
navigate("/terms")
|
||||||
|
} else {
|
||||||
|
return children;
|
||||||
}
|
}
|
||||||
return children;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
navigate("/login")
|
navigate("/login")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useNavigate, useSearchParams, Link } from 'react-router-dom';
|
import { useNavigate, useSearchParams, Link, useLocation } from 'react-router-dom';
|
||||||
import { loginUser } from "../features/user/userSlice";
|
import { useSelector, useDispatch } from 'react-redux'
|
||||||
import { useDispatch } from 'react-redux';
|
import { loginUser } from "../features/user/userSlice";
|
||||||
import {
|
import {
|
||||||
Container,
|
Container,
|
||||||
Header,
|
Header,
|
||||||
@@ -28,27 +28,31 @@ const forgotStyle = {
|
|||||||
|
|
||||||
|
|
||||||
const Login = (props) => {
|
const Login = (props) => {
|
||||||
|
const { terms } = useSelector((state) => state.user);
|
||||||
const [loginMessage, setLoginMessage] = useState("");
|
const [loginMessage, setLoginMessage] = useState("");
|
||||||
const [email, setEmail] = useState("");
|
const [email, setEmail] = useState("");
|
||||||
const [password, setPassword] = useState("");
|
const [password, setPassword] = useState("");
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
let [searchParams] = useSearchParams();
|
let [searchParams] = useSearchParams();
|
||||||
const nextLocation = searchParams.get("nextLocation");
|
const nextLocation = searchParams.get("nextLocation");
|
||||||
|
const location = useLocation();
|
||||||
|
const { hash, pathname, search } = location;
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const loginSubmit = async (event) => {
|
const loginSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const result = await dispatch(loginUser({email,password})).unwrap();
|
const result = await dispatch(loginUser({ email, password })).unwrap();
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
if ((pathname != "/terms") && (terms != 1.1)) {
|
||||||
if (nextLocation) {
|
navigate("/terms")
|
||||||
|
} else if (nextLocation) {
|
||||||
switch (nextLocation) {
|
switch (nextLocation) {
|
||||||
case "frontend":
|
case "frontend":
|
||||||
window.location = process.env.REACT_APP_FRONTEND_SERVER;
|
window.location = process.env.REACT_APP_FRONTEND_SERVER;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case "admin":
|
case "admin":
|
||||||
window.location = process.env.REACT_APP_ADMIN_SERVER;
|
window.location = process.env.REACT_APP_ADMIN_SERVER;
|
||||||
break;
|
break;
|
||||||
case "account":
|
case "account":
|
||||||
navigate("/");
|
navigate("/");
|
||||||
@@ -56,7 +60,7 @@ const Login = (props) => {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
navigate("/");
|
navigate("/");
|
||||||
}
|
}
|
||||||
console.log(result)
|
console.log(result)
|
||||||
} else {
|
} else {
|
||||||
console.error(result);
|
console.error(result);
|
||||||
@@ -73,113 +77,113 @@ const Login = (props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let loginMessageDisplay =(<></>)
|
let loginMessageDisplay = (<></>)
|
||||||
|
|
||||||
if (loginMessage) {
|
if (loginMessage) {
|
||||||
loginMessageDisplay = (
|
loginMessageDisplay = (
|
||||||
<Message icon>
|
<Message icon>
|
||||||
<Icon name="lemon" />
|
<Icon name="lemon" />
|
||||||
<Message.Content>
|
<Message.Content>
|
||||||
<Message.Header>Problems...</Message.Header>
|
<Message.Header>Problems...</Message.Header>
|
||||||
{loginMessage}
|
{loginMessage}
|
||||||
</Message.Content>
|
</Message.Content>
|
||||||
</Message>
|
</Message>
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Container>
|
|
||||||
<Header as="h1">{process.env.REACT_APP_SITE_NAME}</Header>
|
|
||||||
<Grid stackable >
|
|
||||||
<Grid.Row>
|
|
||||||
<Grid.Column width={9}>
|
|
||||||
|
|
||||||
<Header size="large">Let's get this started!</Header>
|
|
||||||
<Header size="small">
|
|
||||||
{process.env.REACT_APP_SITE_NAME} makes it easy to share recordings from{" "}
|
|
||||||
<a href="https://github.com/robotastic/trunk-recorder">
|
|
||||||
Trunk Recorder
|
|
||||||
</a>.</Header>
|
|
||||||
<p>
|
|
||||||
Trunk Recorder makes it easy to record the radio systems
|
|
||||||
used by your local police and fire department. Trunk Recorder
|
|
||||||
is sort of like an awesome version of those Scanners from
|
|
||||||
Radio Shack... 10-4!
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
This site is a work in progress. I plan on adding more
|
|
||||||
features over time, but right now it can:
|
|
||||||
</p>
|
|
||||||
<ul>
|
|
||||||
<li>30 day archive</li>
|
|
||||||
<li>Filter by talkgroup</li>
|
|
||||||
</ul>
|
|
||||||
<p>
|
|
||||||
All of this goodness is free! In the future, I might offer
|
|
||||||
paid accounts with additional features and a longer archive
|
|
||||||
period, but I will always try to have a free version.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
{" "}
|
|
||||||
- Luke{" "}
|
|
||||||
<a
|
|
||||||
href="mailto:{process.env.REACT_APP_ADMIN_EMAIL}?Subject={process.env.REACT_APP_SITE_NAME}"
|
|
||||||
target="_top"
|
|
||||||
>
|
|
||||||
admin@email.com
|
|
||||||
</a>{" "}
|
|
||||||
</p>
|
|
||||||
</Grid.Column>
|
|
||||||
<Grid.Column floated="right" width={6}>
|
|
||||||
<Header as="h3">Need an account?</Header>
|
|
||||||
<Button
|
|
||||||
size="large"
|
|
||||||
content="Register"
|
|
||||||
onClick={()=>navigate("/register")}
|
|
||||||
fluid
|
|
||||||
/>
|
|
||||||
<Divider style={dividerStyle} horizontal>Or</Divider>
|
|
||||||
<Header as="h3">Login</Header>
|
|
||||||
<Form onSubmit={loginSubmit}>
|
|
||||||
<Segment padded>
|
|
||||||
<Form.Field>
|
|
||||||
<Form.Input
|
|
||||||
icon="user"
|
|
||||||
iconPosition="left"
|
|
||||||
type="text"
|
|
||||||
name="email"
|
|
||||||
onChange={e => setEmail(e.target.value)}
|
|
||||||
value={email}
|
|
||||||
placeholder="E-mail address"
|
|
||||||
/>
|
|
||||||
</Form.Field>
|
|
||||||
<Form.Field>
|
|
||||||
<Form.Input
|
|
||||||
icon="lock"
|
|
||||||
iconPosition="left"
|
|
||||||
type="password"
|
|
||||||
name="password"
|
|
||||||
value={password}
|
|
||||||
onChange={e => setPassword(e.target.value)}
|
|
||||||
placeholder="Password"
|
|
||||||
/>
|
|
||||||
</Form.Field>
|
|
||||||
|
|
||||||
<Button type="submit" size="large" value="Login" fluid>
|
|
||||||
Login
|
|
||||||
</Button>
|
|
||||||
{loginMessageDisplay}
|
|
||||||
</Segment>
|
|
||||||
</Form>
|
|
||||||
<div style={forgotStyle} >
|
|
||||||
<Link to="/send-reset-password">Forgot Password</Link>
|
|
||||||
</div>
|
|
||||||
</Grid.Column>
|
|
||||||
</Grid.Row>
|
|
||||||
</Grid>
|
|
||||||
</Container>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<Header as="h1">{process.env.REACT_APP_SITE_NAME}</Header>
|
||||||
|
<Grid stackable >
|
||||||
|
<Grid.Row>
|
||||||
|
<Grid.Column width={9}>
|
||||||
|
|
||||||
|
<Header size="large">Let's get this started!</Header>
|
||||||
|
<Header size="small">
|
||||||
|
{process.env.REACT_APP_SITE_NAME} makes it easy to share recordings from{" "}
|
||||||
|
<a href="https://github.com/robotastic/trunk-recorder">
|
||||||
|
Trunk Recorder
|
||||||
|
</a>.</Header>
|
||||||
|
<p>
|
||||||
|
Trunk Recorder makes it easy to record the radio systems
|
||||||
|
used by your local police and fire department. Trunk Recorder
|
||||||
|
is sort of like an awesome version of those Scanners from
|
||||||
|
Radio Shack... 10-4!
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
This site is a work in progress. I plan on adding more
|
||||||
|
features over time, but right now it can:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>30 day archive</li>
|
||||||
|
<li>Filter by talkgroup</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
All of this goodness is free! In the future, I might offer
|
||||||
|
paid accounts with additional features and a longer archive
|
||||||
|
period, but I will always try to have a free version.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{" "}
|
||||||
|
- Luke{" "}
|
||||||
|
<a
|
||||||
|
href="mailto:{process.env.REACT_APP_ADMIN_EMAIL}?Subject={process.env.REACT_APP_SITE_NAME}"
|
||||||
|
target="_top"
|
||||||
|
>
|
||||||
|
admin@email.com
|
||||||
|
</a>{" "}
|
||||||
|
</p>
|
||||||
|
</Grid.Column>
|
||||||
|
<Grid.Column floated="right" width={6}>
|
||||||
|
<Header as="h3">Need an account?</Header>
|
||||||
|
<Button
|
||||||
|
size="large"
|
||||||
|
content="Register"
|
||||||
|
onClick={() => navigate("/register")}
|
||||||
|
fluid
|
||||||
|
/>
|
||||||
|
<Divider style={dividerStyle} horizontal>Or</Divider>
|
||||||
|
<Header as="h3">Login</Header>
|
||||||
|
<Form onSubmit={loginSubmit}>
|
||||||
|
<Segment padded>
|
||||||
|
<Form.Field>
|
||||||
|
<Form.Input
|
||||||
|
icon="user"
|
||||||
|
iconPosition="left"
|
||||||
|
type="text"
|
||||||
|
name="email"
|
||||||
|
onChange={e => setEmail(e.target.value)}
|
||||||
|
value={email}
|
||||||
|
placeholder="E-mail address"
|
||||||
|
/>
|
||||||
|
</Form.Field>
|
||||||
|
<Form.Field>
|
||||||
|
<Form.Input
|
||||||
|
icon="lock"
|
||||||
|
iconPosition="left"
|
||||||
|
type="password"
|
||||||
|
name="password"
|
||||||
|
value={password}
|
||||||
|
onChange={e => setPassword(e.target.value)}
|
||||||
|
placeholder="Password"
|
||||||
|
/>
|
||||||
|
</Form.Field>
|
||||||
|
|
||||||
|
<Button type="submit" size="large" value="Login" fluid>
|
||||||
|
Login
|
||||||
|
</Button>
|
||||||
|
{loginMessageDisplay}
|
||||||
|
</Segment>
|
||||||
|
</Form>
|
||||||
|
<div style={forgotStyle} >
|
||||||
|
<Link to="/send-reset-password">Forgot Password</Link>
|
||||||
|
</div>
|
||||||
|
</Grid.Column>
|
||||||
|
</Grid.Row>
|
||||||
|
</Grid>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default Login;
|
export default Login;
|
||||||
|
|||||||
Reference in New Issue
Block a user