# Firebase Auth Rules and Problems

**URL:** <https://community.thunkable.com/t/firebase-auth-rules-and-problems/1910874>\
**Category:** Questions about Thunkable X\
**Tags:** firebase, auth\
**Created:** [June 5, 2022, 7:18am UTC](https://community.thunkable.com/t/firebase-auth-rules-and-problems/1910874 "2022-06-05T07:18:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![griggril000](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/griggril000/32/142351_2.png) [@griggril000](https://community.thunkable.com/u/griggril000)\
**Post date:** [June 5, 2022, 7:18am UTC](https://community.thunkable.com/t/firebase-auth-rules-and-problems/1910874/1 "2022-06-05T07:18:52Z")

</div>

I am working on a goals app and storing with Firebase Realtime Database. Everything works fine until I close the app and open it again.  
I am still logged in, but I can’t update the database through my app as I could when I first logged in.

**My Firebase Rules:**

```auto
{
  "rules": {
    "$user_id": {
    ".write": "$user_id === auth.uid",
".read": "$user_id === auth.uid"
    }
  }
}

```

Any idea what my problem is? Is it something on my end or somewhere in Thunkable or Google?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [June 5, 2022, 7:26am UTC](https://community.thunkable.com/t/firebase-auth-rules-and-problems/1910874/2 "2022-06-05T07:26:21Z")

</div>

How do you know you are still logged in to Firebase? Are there app variables you are using that should instead be stored variables so that they save their values when you re-open the app?

What do your blocks look like for Sign In?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [June 7, 2022, 2:33pm UTC](https://community.thunkable.com/t/firebase-auth-rules-and-problems/1910874/3 "2022-06-07T14:33:02Z")

</div>

You have to log in every time you start the app.

---

<div class="post-metadata">

**Author:** ![griggril000](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/griggril000/32/142351_2.png) [@griggril000](https://community.thunkable.com/u/griggril000)\
**Post date:** [June 7, 2022, 4:59pm UTC](https://community.thunkable.com/t/firebase-auth-rules-and-problems/1910874/4 "2022-06-07T16:59:13Z")

</div>

I guess I don’t know. I store everything either as stored or cloud variables. I don’t tell Firebase to log out unless a button is clicked. My sign in blocks say as long as there’s not an error passed, and the email is verified, store the user ID as a stored variable, and make a stored variable isLoggedIn to true so they stay logged in from my app’s perspective until they click the log out button.

Riley Grigg

---

<div class="post-metadata">

**Author:** ![griggril000](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/griggril000/32/142351_2.png) [@griggril000](https://community.thunkable.com/u/griggril000)\
**Post date:** [June 7, 2022, 5:00pm UTC](https://community.thunkable.com/t/firebase-auth-rules-and-problems/1910874/5 "2022-06-07T17:00:18Z")

</div>

Ok. Is there a way to log in in the background if the user hasn’t chosen to click the logout button?

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [June 7, 2022, 5:36pm UTC](https://community.thunkable.com/t/firebase-auth-rules-and-problems/1910874/6 "2022-06-07T17:36:32Z")

</div>

> [@griggril000](#):
>
> My sign in blocks say as long as there’s not an error passed, and the email is verified, store the user ID as a stored variable, and make a stored variable isLoggedIn to true

Firebase use `session token` to identify logged in users so whenever the user closes the app, the session token is destroyed.

One way is to use the `stored` user name and password and automatically log the user in next time the app is used and the `IsLoggedIn` is set to true. This way a new session token will be established so you can access Firebase Realtime DB.

---

<div class="post-metadata">

**Author:** ![griggril000](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/griggril000/32/142351_2.png) [@griggril000](https://community.thunkable.com/u/griggril000)\
**Post date:** [June 7, 2022, 5:55pm UTC](https://community.thunkable.com/t/firebase-auth-rules-and-problems/1910874/7 "2022-06-07T17:55:54Z")

</div>

Ok. Thank you!

Riley Grigg

---

<div class="post-metadata">

**Author:** ![griggril000](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/griggril000/32/142351_2.png) [@griggril000](https://community.thunkable.com/u/griggril000)\
**Post date:** [June 7, 2022, 7:03pm UTC](https://community.thunkable.com/t/firebase-auth-rules-and-problems/1910874/8 "2022-06-07T19:03:38Z")

</div>

That did it. Thanks!

Riley Grigg

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [September 5, 2022, 7:04pm UTC](https://community.thunkable.com/t/firebase-auth-rules-and-problems/1910874/9 "2022-09-05T19:04:03Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
