# Directly login a user if current userid is not null

**URL:** https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762
**Category:** Questions about Thunkable X
**Tags:** firebase, beginner
**Created:** [March 30, 2019, 2:17pm UTC](https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762 "2019-03-30T14:17:40Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![user12](https://avatars.discourse-cdn.com/v4/letter/u/e0b2c6/32.png) [@user12](https://community.thunkable.com/u/user12)
#### Post date: [March 30, 2019, 2:17pm UTC](https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762/1 "2019-03-30T14:17:40Z")

</div>

Hello,

I’ve spent a solid 30 minutes searching for a solution to my problem in the topics posted but couldn’t find any, so if this is a duplicate and is already solved please link it to me.

if not, the problem is I am trying to directly make the user login to his account if he already logged in before and did not log out.

Here is the block of what I tried to do, I also tried other things that did not work.

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/e/2e26b112f5ceb27db14348453a052cf7a6620945.png)

I do know that the problem is in “userId” that should only be used in the “Sign in” method but it is asking for a password and e-mail that I am unable to provide.

Any help would be much appreciated!

---

<div class="post-metadata">

### Author: ![cttricks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cttricks/32/93678_2.png) [@cttricks](https://community.thunkable.com/u/cttricks)
#### Post date: [March 30, 2019, 3:36pm UTC](https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762/2 "2019-03-30T15:36:38Z")

</div>

So what you all need to do is, you have to store the user id in a local storage with a tag [ID] during signup process and when the user re-opens the app then on splash screen check if the tag [ID] of the local storage is not equal to blank then send user to the home screen else send to signup/login screen

---

<div class="post-metadata">

### Author: ![user12](https://avatars.discourse-cdn.com/v4/letter/u/e0b2c6/32.png) [@user12](https://community.thunkable.com/u/user12)
#### Post date: [March 30, 2019, 3:41pm UTC](https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762/3 "2019-03-30T15:41:09Z")

</div>

Seems logical, and then when he presses logout i remove him from the local DB right?

---

<div class="post-metadata">

### Author: ![cttricks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cttricks/32/93678_2.png) [@cttricks](https://community.thunkable.com/u/cttricks)
#### Post date: [March 30, 2019, 3:43pm UTC](https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762/4 "2019-03-30T15:43:13Z")

</div>

Yup when the user hits the logout button set the vaue of the tag [ID] to blank.

---

<div class="post-metadata">

### Author: ![user12](https://avatars.discourse-cdn.com/v4/letter/u/e0b2c6/32.png) [@user12](https://community.thunkable.com/u/user12)
#### Post date: [March 30, 2019, 3:57pm UTC](https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762/5 "2019-03-30T15:57:51Z")

</div>

I tried it out, here’s the code

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/3/f3dd9e07d624061fd9dbdfc06aba246d72ecad00.png)

Thats once he logs in.

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/5/653c500140a988526126959c992158382555f11f.png)

This is when he relaunches the app

If this code is correct it is not working for me 😛

---

<div class="post-metadata">

### Author: ![cttricks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cttricks/32/93678_2.png) [@cttricks](https://community.thunkable.com/u/cttricks)
#### Post date: [March 30, 2019, 4:47pm UTC](https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762/6 "2019-03-30T16:47:12Z")

</div>

Hello @user12  
Here is a demo project link to understand the working of one time signin system.

🔗 [https://x.thunkable.com/copy/c44e9a46357df8e406d05d9a0da4a86b](https://x.thunkable.com/copy/c44e9a46357df8e406d05d9a0da4a86b)

//Ct tricks

---

<div class="post-metadata">

### Author: ![user12](https://avatars.discourse-cdn.com/v4/letter/u/e0b2c6/32.png) [@user12](https://community.thunkable.com/u/user12)
#### Post date: [April 2, 2019, 7:36pm UTC](https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762/7 "2019-04-02T19:36:54Z")

</div>

Hello @cttricks

After 3 days of trial and error I got it to work thanks to your help, I marked you reply as the solution!

Thank you!

---

<div class="post-metadata">

### Author: ![cttricks](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cttricks/32/93678_2.png) [@cttricks](https://community.thunkable.com/u/cttricks)
#### Post date: [April 2, 2019, 7:38pm UTC](https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762/8 "2019-04-02T19:38:09Z")

</div>

You welcome 😊

---

<div class="post-metadata">

### Author: ![domhnallohanlon](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/domhnallohanlon/32/29554_2.png) [@domhnallohanlon](https://community.thunkable.com/u/domhnallohanlon)
#### Post date: [April 3, 2019, 11:17am UTC](https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762/9 "2019-04-03T11:17:44Z")

</div>

Just for the benefit of any future community members who run into this issue, we also have a video outlining how to use the sign in component here:

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 12:15pm UTC](https://community.thunkable.com/t/directly-login-a-user-if-current-userid-is-not-null/73762/10 "2024-11-08T12:15:54Z")

</div>


