fixing sign out issues
This commit is contained in:
@@ -82,8 +82,6 @@ export default function Header() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await logOut();
|
await logOut();
|
||||||
|
|
||||||
router.push("/teams/landing");
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
toast.error("Unable to log out!");
|
toast.error("Unable to log out!");
|
||||||
|
|||||||
@@ -41,8 +41,24 @@ export default function PowerPlayer(props: {
|
|||||||
handleAddAudioToQueue([url]);
|
handleAddAudioToQueue([url]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleClose(e) {
|
||||||
|
props.handleCloseModal();
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal title="Power Playback " visible={props.show}>
|
<Modal
|
||||||
|
title="Power Playback "
|
||||||
|
visible={props.show}
|
||||||
|
onCancel={handleClose}
|
||||||
|
footer={
|
||||||
|
<button
|
||||||
|
onClick={handleClose}
|
||||||
|
className="ml-auto text-sm text-orange-500 font-semibold py-1 px-4 bg-gray-200 rounded"
|
||||||
|
>
|
||||||
|
👋 Close
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
>
|
||||||
<span className="flex flex-col items-start">
|
<span className="flex flex-col items-start">
|
||||||
<span>One timeline to listen to the past 24 hours.</span>
|
<span>One timeline to listen to the past 24 hours.</span>
|
||||||
|
|
||||||
|
|||||||
+12
-2
@@ -6,8 +6,10 @@ import {
|
|||||||
signOut,
|
signOut,
|
||||||
User,
|
User,
|
||||||
} from "firebase/auth";
|
} from "firebase/auth";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
import React, { useContext, useEffect, useState } from "react";
|
import React, { useContext, useEffect, useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
|
import Loading from "../components/Loading";
|
||||||
import firebase from "../services/firebaseService";
|
import firebase from "../services/firebaseService";
|
||||||
|
|
||||||
const AuthContext = React.createContext(null);
|
const AuthContext = React.createContext(null);
|
||||||
@@ -19,8 +21,12 @@ export function AuthProvider({ children }) {
|
|||||||
const [currUser, setCurrUser] = useState();
|
const [currUser, setCurrUser] = useState();
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unsubscribe = onAuthStateChanged(auth, async (user) => {
|
const unsubscribe = onAuthStateChanged(auth, async (user) => {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
console.log("change in auth");
|
console.log("change in auth");
|
||||||
if (user) {
|
if (user) {
|
||||||
setCurrUser(user);
|
setCurrUser(user);
|
||||||
@@ -67,10 +73,14 @@ export function AuthProvider({ children }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const logOut = () => {
|
const logOut = async () => {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
console.log("logging user out");
|
console.log("logging user out");
|
||||||
|
|
||||||
return signOut(auth);
|
Promise.resolve(await signOut(auth));
|
||||||
|
|
||||||
|
router.push("/teams/landing");
|
||||||
};
|
};
|
||||||
|
|
||||||
const value = {
|
const value = {
|
||||||
|
|||||||
@@ -50,8 +50,11 @@ const db = getFirestore();
|
|||||||
|
|
||||||
export function TeamDashboardContextProvider({ children }) {
|
export function TeamDashboardContextProvider({ children }) {
|
||||||
const { currUser } = useAuth();
|
const { currUser } = useAuth();
|
||||||
const [loading, setLoading] = useState<Boolean>(true);
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
const [loading, setLoading] = useState<Boolean>(true);
|
||||||
|
|
||||||
const { teamid } = router.query;
|
const { teamid } = router.query;
|
||||||
|
|
||||||
// this context can only be used if it's a specific route: '/teams'
|
// this context can only be used if it's a specific route: '/teams'
|
||||||
@@ -212,7 +215,9 @@ export function TeamDashboardContextProvider({ children }) {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
userListener();
|
if (userListener) {
|
||||||
|
userListener();
|
||||||
|
}
|
||||||
|
|
||||||
unsubs.forEach((unsub) => {
|
unsubs.forEach((unsub) => {
|
||||||
unsub();
|
unsub();
|
||||||
@@ -232,6 +237,12 @@ export function TeamDashboardContextProvider({ children }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// todo for new messages, change document.title
|
// todo for new messages, change document.title
|
||||||
|
|
||||||
|
if (!currUser) {
|
||||||
|
console.log("not authenticated...routing from dashboard to teams home");
|
||||||
|
router.push("/teams/login");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QUERY:
|
* QUERY:
|
||||||
* - last 24 hours only
|
* - last 24 hours only
|
||||||
|
|||||||
Reference in New Issue
Block a user