This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { createContext, useReducer } from 'react'; | |
import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; | |
import Home from "./components/Home"; | |
import Login from "./components/Login"; | |
import { initialState, reducer } from "./store/reducer"; | |
export const AuthContext = createContext(); | |
function App() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const initialState = { | |
isLoggedIn: JSON.parse(localStorage.getItem("isLoggedIn")) || false, | |
user: JSON.parse(localStorage.getItem("user")) || null, | |
client_id: process.env.REACT_APP_CLIENT_ID, | |
redirect_uri: process.env.REACT_APP_REDIRECT_URI, | |
client_secret: process.env.REACT_APP_CLIENT_SECRET, | |
proxy_url: process.env.REACT_APP_PROXY_URL | |
}; | |
export const reducer = (state, action) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect, useContext } from "react"; | |
import { Redirect } from "react-router-dom"; | |
import Styled from "styled-components"; | |
import GithubIcon from "mdi-react/GithubIcon"; | |
import { AuthContext } from "../App"; | |
export default function Login() { | |
const { state, dispatch } = useContext(AuthContext); | |
const [data, setData] = useState({ errorMessage: "", isLoading: false }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useContext } from "react"; | |
import { Redirect } from "react-router-dom"; | |
import Styled from "styled-components"; | |
import { AuthContext } from "../App"; | |
export default function Home() { | |
const { state, dispatch } = useContext(AuthContext); | |
if (!state.isLoggedIn) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const bodyParser = require("body-parser"); | |
const FormData = require("form-data"); | |
const fetch = require("node-fetch"); | |
const { client_id, redirect_uri, client_secret } = require("./config"); | |
const config = require("./config"); | |
const app = express(); |