diff --git a/webclient/public/wikilogo.png b/webclient/public/wikilogo.png new file mode 100644 index 0000000..228f352 Binary files /dev/null and b/webclient/public/wikilogo.png differ diff --git a/webclient/src/App.js b/webclient/src/App.js index d1d036a..9a5dcc3 100644 --- a/webclient/src/App.js +++ b/webclient/src/App.js @@ -19,6 +19,7 @@ import { Courses, CourseDetail } from './Courses.js'; import { Classes, ClassDetail } from './Classes.js'; import { Members, MemberDetail } from './Members.js'; import { Charts } from './Charts.js'; +import { Auth } from './Auth.js'; import { PasswordReset, ConfirmReset } from './PasswordReset.js'; import { NotFound, PleaseLogin } from './Misc.js'; import { Footer } from './Footer.js'; @@ -216,6 +217,10 @@ function App() { + + + + {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.

+ + + + +
+ ); +}