mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-09-25 00:13:12 +08:00
removes hardcoding--2
This commit is contained in:
parent
d5cb191299
commit
c8b92ce4d5
1
frontend/src/constants/auth.ts
Normal file
1
frontend/src/constants/auth.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const IS_LOGGED_IN = "isLoggedIn";
|
@ -2,6 +2,7 @@ import React, { Suspense } from "react";
|
|||||||
import { Layout, Spin } from "antd";
|
import { Layout, Spin } from "antd";
|
||||||
import { useThemeSwitcher } from "react-css-theme-switcher";
|
import { useThemeSwitcher } from "react-css-theme-switcher";
|
||||||
import ROUTES from "Src/constants/routes";
|
import ROUTES from "Src/constants/routes";
|
||||||
|
import { IS_LOGGED_IN } from "Src/constants/auth";
|
||||||
import {
|
import {
|
||||||
BrowserRouter as Router,
|
BrowserRouter as Router,
|
||||||
Route,
|
Route,
|
||||||
@ -58,7 +59,7 @@ const App = () => {
|
|||||||
path="/"
|
path="/"
|
||||||
exact
|
exact
|
||||||
render={() => {
|
render={() => {
|
||||||
return localStorage.getItem("isLoggedIn") === "yes" ? (
|
return localStorage.getItem(IS_LOGGED_IN) === "yes" ? (
|
||||||
<Redirect to={ROUTES.APPLICATION} />
|
<Redirect to={ROUTES.APPLICATION} />
|
||||||
) : (
|
) : (
|
||||||
<Redirect to={ROUTES.SIGN_UP} />
|
<Redirect to={ROUTES.SIGN_UP} />
|
||||||
|
@ -2,6 +2,7 @@ import React, { useState } from "react";
|
|||||||
import { Row, Space, Button, Input } from "antd";
|
import { Row, Space, Button, Input } from "antd";
|
||||||
import api, { apiV1 } from "../../api";
|
import api, { apiV1 } from "../../api";
|
||||||
import ROUTES from "Src/constants/routes";
|
import ROUTES from "Src/constants/routes";
|
||||||
|
import { IS_LOGGED_IN } from "Src/constants/auth";
|
||||||
|
|
||||||
import { withRouter } from "react-router";
|
import { withRouter } from "react-router";
|
||||||
import { RouteComponentProps } from "react-router-dom";
|
import { RouteComponentProps } from "react-router-dom";
|
||||||
@ -36,8 +37,6 @@ const Signup = (props: SignUpProps) => {
|
|||||||
const handleSubmit = (e: any) => {
|
const handleSubmit = (e: any) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
console.log("in handle submit");
|
|
||||||
|
|
||||||
setState({ ...state, submitted: true });
|
setState({ ...state, submitted: true });
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
@ -52,7 +51,7 @@ const Signup = (props: SignUpProps) => {
|
|||||||
console.log(res.data);
|
console.log(res.data);
|
||||||
});
|
});
|
||||||
|
|
||||||
localStorage.setItem("isLoggedIn", "yes");
|
localStorage.setItem(IS_LOGGED_IN, "yes");
|
||||||
props.history.push(ROUTES.APPLICATION);
|
props.history.push(ROUTES.APPLICATION);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user