redirect to user account after successful sign in

This commit is contained in:
Ruidy Nemausat 2020-05-05 13:45:44 +02:00
parent 9f6b3344b1
commit e3a1fa0d0a
3 changed files with 29 additions and 16 deletions

View file

@ -0,0 +1,7 @@
export const HOME: string = "/";
export const PROJECTS: string = "/projects";
export const TICKETS: string = "/tickets";
export const USERS: string = "/users";
export const SIGN_IN: string = "/signin";
export const NOT_FOUND: string = "/404";
export const TEST: string = "/test";

View file

@ -2,24 +2,10 @@ import React, { FC } from "react";
// import { LogInForm } from "../components/LogInForm";
// import { ProfileSelector } from "../components/ProfileSelector";
import SignInSide from "../components/SignInSide";
import { useAuth0 } from "../authentication/auth0";
const HomePage: FC = () => {
return (
// <div className="section">
// <div className="container center">
// <h1 className="center">Ticket Manager</h1>
// <div className="row">
// <div className="col s6">
// <ProfileSelector />
// </div>
// <div className="col s6">
// <LogInForm />
// </div>
// </div>
// </div>
// </div>
<SignInSide />
);
return <div>HomePage</div>;
};
export default HomePage;

View file

@ -0,0 +1,20 @@
import React, { FC } from "react";
import SignInSide from "../components/SignInSide";
import { useAuth0 } from "../authentication/auth0";
import { Redirect } from "react-router-dom";
import * as ROUTES from "../constants/routes";
const SigninPage: FC = () => {
const { isAuthenticated, user } = useAuth0();
if (isAuthenticated) {
// retrieve userId
const { sub } = user;
const uid = sub.split("|")[1];
return <Redirect to={`${ROUTES.USERS}/${uid}`} />;
} else {
return <SignInSide />;
}
};
export default SigninPage;