Send bypass code to server from UI

This commit is contained in:
Tanner Collin 2020-06-11 01:18:26 +00:00
parent f23c3ecc4c
commit e099490f8b

View File

@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } 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 './light.css'; import './light.css';
import { Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Message, Segment, Table } from 'semantic-ui-react'; import { Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Message, Segment, Table } from 'semantic-ui-react';
import { requester } from './utils.js'; import { requester } from './utils.js';
@ -70,6 +70,9 @@ export function SignupForm(props) {
const [input, setInput] = useState({ email: '' }); const [input, setInput] = useState({ email: '' });
const [error, setError] = useState({}); const [error, setError] = useState({});
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const location = useLocation();
const bypass_code = location.hash.replace('#', '');
const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value }); const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value });
const handleChange = (e) => handleValues(e, e.currentTarget); const handleChange = (e) => handleValues(e, e.currentTarget);
@ -85,7 +88,7 @@ export function SignupForm(props) {
if (loading) return; if (loading) return;
setLoading(true); setLoading(true);
input.username = genUsername(); input.username = genUsername();
const data = { ...input, email: input.email.toLowerCase() }; const data = { ...input, email: input.email.toLowerCase(), bypass_code: bypass_code };
requester('/registration/', 'POST', '', data) requester('/registration/', 'POST', '', data)
.then(res => { .then(res => {
setError({}); setError({});