Skip to content

Commit

Permalink
Use cookies on club login (#265)
Browse files Browse the repository at this point in the history
* Update README.md

* add a banner for clubs

* fix: change clubs banner size

* Add cookies to user login

* add cookies to club login

Co-authored-by: Tamal Das <[email protected]>
  • Loading branch information
roei111 and tamalCodes authored Aug 20, 2022
1 parent 42af8ab commit f58b64c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Navbar = () => {
navigate("/user/profile");
}

if (sessionStorage.getItem("club")) {
if (Cookies.get("club")) {
navigate("/clubs/profile");
}
};
Expand Down Expand Up @@ -74,7 +74,7 @@ const Navbar = () => {
{/* Auth0 will be implemented later on*/}
{/* The basic JWT Auths will be removed to reduce hassle */}

{(Cookies.get("token") || sessionStorage.getItem("club")) &&
{(Cookies.get("token") || Cookies.get("club")) &&
<img
onClick={handleNavigate}
src={ProfilePicture}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ClubBanner from "../components/ClubBanner";
import Cookies from "js-cookie";

const AuthState = () => {
const [login, setLogin] = useState(Cookies.get("token") || sessionStorage.getItem("club"));
const [login, setLogin] = useState(Cookies.get("token") || Cookies.get("club"));
return login;
};
const Home = () => {
Expand All @@ -21,7 +21,7 @@ const Home = () => {
{AuthState() ? <LoginBanner /> : <Banner />}
<HomeCardsContainer />
<DonateBanner />
{sessionStorage.getItem("club") ? <ClubBanner /> : <EventsBanner />}
{Cookies.get("club") ? <ClubBanner /> : <EventsBanner />}
<Footer />
</>
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/clubs/ClubProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React from 'react'
import { useNavigate } from 'react-router-dom'
import comingsoon from '../../assets/pictures/comingsoon.svg'
import Navbar from '../../components/Navbar'

import Cookies from "js-cookie";

const ClubProfile = () => {
const Navigate = useNavigate()

const handleLogout = () => {
window.alert("Logout successful !")
sessionStorage.removeItem("club")
Cookies.remove("club");
Navigate("/clubs/login")

}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/clubs/ClubsLogin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { LoginClub } from "../../service/MilanApi";
import { Audio, Oval, TailSpin } from "react-loader-spinner";
import { toast, ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

import Cookies from 'js-cookie';


function ClubLogin() {
Expand Down Expand Up @@ -52,8 +52,8 @@ function ClubLogin() {

Data.then((response) => {
if (response.data.success === true) {

sessionStorage.setItem("club", response.data.authToken);
Cookies.set("club",response.data.authToken);

toast('🌈 Logged you in !', {
position: "top-right",
Expand Down

1 comment on commit f58b64c

@vercel
Copy link

@vercel vercel bot commented on f58b64c Aug 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

milan – ./

milaan.vercel.app
milan-git-main-iamtamal.vercel.app
milan-iamtamal.vercel.app

Please sign in to comment.