Created envars and updated config flow
This commit is contained in:
parent
0e424ec5fa
commit
d4b5a555b9
12 changed files with 56 additions and 62 deletions
24
src/Stash.js
24
src/Stash.js
|
@ -1,16 +1,14 @@
|
|||
//Module Imports
|
||||
// Module Imports
|
||||
import React from "react";
|
||||
import axios from "axios";
|
||||
import { ToastContainer } from "react-toastify";
|
||||
import "react-toastify/dist/ReactToastify.css";
|
||||
//Local Imports
|
||||
// Local Imports
|
||||
import StashBoard from "./stash/StashBoard";
|
||||
import { api } from "./config.json";
|
||||
|
||||
const getCairoApiInstance = (cairoAuthToken) =>
|
||||
axios.create({
|
||||
headers: { Authorization: `Bearer ${cairoAuthToken}` },
|
||||
});
|
||||
axios.create({ headers: { Authorization: `Bearer ${cairoAuthToken}` } });
|
||||
|
||||
class Stash extends React.Component {
|
||||
constructor(props) {
|
||||
|
@ -28,13 +26,17 @@ class Stash extends React.Component {
|
|||
verifyLocalToken() {
|
||||
const token = localStorage.getItem("cairoAuthToken");
|
||||
axios
|
||||
.get(api.cairo.verify, { headers: { authorization: `Bearer ${token}` } })
|
||||
.get(api.cairo.urls.verify, {
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
})
|
||||
.then(() => this.setState({ cairoApi: getCairoApiInstance(token) }))
|
||||
.catch(() =>
|
||||
window.location.replace(
|
||||
`${api.cairo.login}?redirectUri=${window.location.href}`
|
||||
)
|
||||
);
|
||||
.catch((error) => {
|
||||
if (error.response && error.response.status === 401)
|
||||
return window.location.replace(
|
||||
`${process.env.REACT_APP_CAIRO_URL}${api.cairo.urls.login}?redirectUri=${window.location.href}`
|
||||
);
|
||||
console.error("Auth server not up/configured properly!");
|
||||
});
|
||||
}
|
||||
|
||||
setLocalToken(cairoAuthToken) {
|
||||
|
|
Reference in a new issue