mirror of
https://github.com/rjNemo/ticket_manager
synced 2026-06-06 00:36:39 +00:00
redirect to user account after successful sign in
This commit is contained in:
parent
9f6b3344b1
commit
e3a1fa0d0a
3 changed files with 29 additions and 16 deletions
7
client/src/constants/routes.ts
Normal file
7
client/src/constants/routes.ts
Normal 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";
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
20
client/src/pages/SigninPage.tsx
Normal file
20
client/src/pages/SigninPage.tsx
Normal 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;
|
||||
Loading…
Reference in a new issue