diff --git a/client/src/api/auth.js b/client/src/api/auth.js index 661fa6f58..f206a4522 100644 --- a/client/src/api/auth.js +++ b/client/src/api/auth.js @@ -1,19 +1,25 @@ import { request } from './util' import { route } from 'preact-router' -export const login = ({ teamToken }) => { +export const login = ({ teamToken, ctftimeToken }) => { return request('POST', '/auth/login', { - teamToken + teamToken, + ctftimeToken }) .then(resp => { switch (resp.kind) { case 'goodLogin': localStorage.setItem('token', resp.data.authToken) - return route('/challs') + route('/challs') + return case 'badTokenVerification': return { teamToken: resp.message } + case 'badUnknownUser': + return { + badUnknownUser: true + } default: return { teamToken: 'Unknown response from server, please contact ctf administrator' @@ -53,11 +59,12 @@ export const verify = ({ verifyToken }) => { }) } -export const register = ({ email, name, division }) => { +export const register = ({ email, name, division, ctftimeToken }) => { return request('POST', '/auth/register', { email, name, - division: Number.parseInt(division) + division: Number.parseInt(division), + ctftimeToken }) .then(resp => { switch (resp.kind) { @@ -80,3 +87,9 @@ export const register = ({ email, name, division }) => { } }) } + +export const ctftimeCallback = ({ ctftimeCode }) => { + return request('POST', '/integrations/ctftime/callback', { + ctftimeCode + }) +} diff --git a/client/src/components/ctftime-additional.js b/client/src/components/ctftime-additional.js new file mode 100644 index 000000000..b1e51dd76 --- /dev/null +++ b/client/src/components/ctftime-additional.js @@ -0,0 +1,77 @@ +import { Component } from 'preact' +import Form from '../components/form' +import config from '../../../config/client' +import 'linkstate/polyfill' +import withStyles from '../components/jss' +import { register } from '../api/auth' +import UserCircle from '../icons/user-circle.svg' + +export default withStyles({ + root: { + padding: '1.5em' + }, + submit: { + marginTop: '1.5em' + }, + title: { + textAlign: 'center' + } +}, class CtftimeAdditional extends Component { + state = { + showName: false, + disabledButton: false, + division: '', + name: '', + errors: {} + } + + render ({ classes }, { showName, disabledButton, division, name, errors }) { + return ( +