From 72b5fc9357f0100f4cc560c1430f7ea2d849eb40 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 5 Feb 2020 22:31:16 +0200 Subject: Implement account activation --- frontend/src/Activate.js | 36 ++++++++++++++++++++++++++++++++++++ frontend/src/App.js | 2 ++ frontend/src/Register.js | 4 +++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 frontend/src/Activate.js (limited to 'frontend/src') diff --git a/frontend/src/Activate.js b/frontend/src/Activate.js new file mode 100644 index 0000000..8a420f4 --- /dev/null +++ b/frontend/src/Activate.js @@ -0,0 +1,36 @@ +import React, { useEffect, useState } from 'react'; +import axios from './axios'; +import { Link } from '@reach/router'; + +const Activate = ({ activationToken }) => { + const [ data, setData ] = useState({}); + useEffect(() => { + (async () => { + try { + await axios.post('/activate', { activationToken }); + setData({ + message: 'Account succesfully activated. You can now log in.', + }); + } catch (err) { + setData({ + error: err.response.data.error, + }); + } + })(); + }, []); + + return ( +
+

Activating account

+
+
+ {data.error} +
+
{data.message}
+ {data.message && To login page} +
+
+ ); +}; + +export default Activate; diff --git a/frontend/src/App.js b/frontend/src/App.js index 89f3e1c..38d8aef 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -7,6 +7,7 @@ import Home from './Home'; import userState from './UserState'; import './App.css'; import axios from './axios'; +import Activate from './Activate'; const App = () => { useEffect(() => { @@ -28,6 +29,7 @@ const App = () => { + diff --git a/frontend/src/Register.js b/frontend/src/Register.js index 6b04816..97a5992 100644 --- a/frontend/src/Register.js +++ b/frontend/src/Register.js @@ -37,6 +37,9 @@ const Register = () => { + @@ -47,7 +50,6 @@ const Register = () => { Register - {/*
{errors}
*/} ); }; -- cgit v1.3