From 1cdb236a7ee35bfaa7624364c16daf5a94ed1aba Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Fri, 18 Sep 2020 05:04:00 +0000 Subject: [PATCH] Add UI for Spaceport auth --- webclient/public/wikilogo.png | Bin 0 -> 1090 bytes webclient/src/App.js | 5 ++ webclient/src/Auth.js | 132 ++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 webclient/public/wikilogo.png create mode 100644 webclient/src/Auth.js diff --git a/webclient/public/wikilogo.png b/webclient/public/wikilogo.png new file mode 100644 index 0000000000000000000000000000000000000000..228f35244c652adbd5cc8d179e3a47a6f8c57bdd GIT binary patch literal 1090 zcmV-I1ikx-P)n@&zoR8&=EW@mJDb-usAK|(`4KRsrj%`W)$FXqGd*#5bnlkj)r0k>zm)3y*00TlvL_t(|+U?tIbD}U1!0`ow z5fx4W>tk!%>%x(P@Bj5~ZoHe4NY921mTUL-x;p>a1QRS-qa_HeQ^3T%9;&&#PKtheAzfUa)}Mi{?8c$<#b+rLd23vw*>fd5Jw0k9!!%Vpkx6FJK7y z8fgv@xR*6ZRcGMZzQik3S>Y9>2X1+9&#GD;(`}GQ8A_Q1+w{0>iZ}mu<91dRc2djx z_#{9l7Qw@l!fr0R;^vK}T)cU`czCKhU*v%+r?Tt)?2%BN2-_W!NDzQSt z_X*g!T*&$aM4mFMVz3olbooFd%_UsMU@teEV5;uYGk5}=A27a#QpYhT1~)>lzLvz3w%{Z;6|ixF5-E3 z6ySzf(#}QsLw^okIno}as5Z`tAvTxFNdI + + + + {user && user.member.set_details ? diff --git a/webclient/src/Auth.js b/webclient/src/Auth.js new file mode 100644 index 0000000..dabeecc --- /dev/null +++ b/webclient/src/Auth.js @@ -0,0 +1,132 @@ +import React, { useState, useEffect, useReducer } from 'react'; +import { BrowserRouter as Router, Switch, Route, Link, useParams, useLocation } from 'react-router-dom'; +import moment from 'moment-timezone'; +import './light.css'; +import { Container, Divider, Dropdown, Form, Grid, Header, Icon, Image, Menu, Message, Popup, Segment, Table } from 'semantic-ui-react'; +import { statusColor, BasicTable, staticUrl, requester, isAdmin } from './utils.js'; + +export function AuthForm(props) { + const { user } = props; + const username = user ? user.username : ''; + const [input, setInput] = useState({ username: username }); + const [error, setError] = useState({}); + const [success, setSuccess] = useState(false); + const [loading, setLoading] = useState(false); + + const handleValues = (e, v) => setInput({ ...input, [v.name]: v.value }); + const handleChange = (e) => handleValues(e, e.currentTarget); + + const handleSubmit = (e) => { + if (input.username.includes('@')) { + setError({ username: 'Username, not email.' }); + } else { + if (loading) return; + setLoading(true); + const data = { ...input, username: input.username.toLowerCase() }; + requester('/spaceport-auth/login/', 'POST', '', data) + .then(res => { + setSuccess(true); + setError({}); + }) + .catch(err => { + setLoading(false); + console.log(err); + setError(err.data); + }); + } + }; + + return ( + success ? + props.children + : +
+
Log In to Spaceport
+ + {user ? + <> + + : + <> + + } + + + Authorize + + + + Forgot your password? +

Click here to reset it.

+
+ + ); +}; + +export function AuthWiki(props) { + const { user } = props; + + return ( + +
+ + Protospace Wiki +
+ +

would like to request Spaceport authentication.

+ +

URL: wiki.protospace.ca

+ + +
Success!
+

You can now log into the wiki:

+

Protospace Wiki

+
+
+ ); +} + +export function Auth(props) { + const { user } = props; + + return ( + +
Spaceport Auth
+ +

Use this page to link different applications to your Spaceport account.

+ + + + +
+ ); +}