Skip to content

Commit

Permalink
Update Firebase example to use cookies.has() (#4302)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Reuben Tier <64310361+TheOtterlord@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 22, 2023
1 parent 20f3664 commit 41b0250
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/content/docs/en/guides/backend/google-firebase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ import Layout from "../layouts/Layout.astro";
/* Check if the user is authenticated */
const auth = getAuth(app);
const sessionCookie = Astro.cookies.get("session").value;
if (sessionCookie) {
if (Astro.cookies.has("session")) {
const sessionCookie = Astro.cookies.get("session").value;
const decodedCookie = await auth.verifySessionCookie(sessionCookie);
if (decodedCookie) {
return Astro.redirect("/dashboard");
Expand Down Expand Up @@ -431,11 +431,10 @@ import Layout from "../layouts/Layout.astro";
const auth = getAuth(app);
/* Check current session */
const sessionCookie = Astro.cookies.get("session").value;
if (!sessionCookie) {
if (!Astro.cookies.has("session")) {
return Astro.redirect("/signin");
}
const sessionCookie = Astro.cookies.get("session").value;
const decodedCookie = await auth.verifySessionCookie(sessionCookie);
const user = await auth.getUser(decodedCookie.uid);
Expand Down Expand Up @@ -473,8 +472,8 @@ import Layout from "../layouts/Layout.astro";
/* Check if the user is authenticated */
const auth = getAuth(app);
const sessionCookie = Astro.cookies.get("session").value;
if (sessionCookie) {
if (Astro.cookies.has("session")) {
const sessionCookie = Astro.cookies.get("session").value;
const decodedCookie = await auth.verifySessionCookie(sessionCookie);
if (decodedCookie) {
return Astro.redirect("/dashboard");
Expand Down

0 comments on commit 41b0250

Please sign in to comment.