[Solved] Private Login Screen

So I’m making an app (obviously), and I’m quite new to Thunkable. I have managed to set up a login page using firebase and that’s all working ok, but I want to have a screen that you can only access if you’re logged in, while also having it in the menu. That’s a bit complicated: basically, a page in the menu that if you’re not logged in, it sends you to the login page and if you are logged in, it lets you go through to the page. I had a go at it by myself, and couldn’t work it out and couldn’t find any tutorials online. Is it even possible?

Hi, @16josephsrgz! :wave:
Welcome to our Community. :handshake:


Congratulations on your app! :tada:

This method might help you -

  • Grab a Local_Storage component from the component tree (in Designer area).

    image

  • In your Login screen, (when the whole process ends, and you navigate the user to menu) add this block -

    image

  • Next, In the menu screen, when that button is clicked, check if the user is logged in, and only let in if he/she is.

    image


Hope I helped you! :smiley_cat:
Good Luck! :tada:

Thanks! :blush:

2 Likes

Thank you very much for your reply, and I tried it out, however for my menu I am using the Drawer Navigator tool and I’m not entirely sure if your method would work with that tool. Here is my code for the login (I did not come up with this, I copied it off this tutorial):

Screenshot 2020-02-21 at 11.59.31

Hi, @16josephsrgz! :wave:

I see, you have stored the userID as value,

image

Whereas I suggested to store true -

image

So, try storing true, and then check it :+1:

Thanks! :blush:

2 Likes

This quick fix works very well, thank you! However another problem has arisen, when you arrive on the login page, and then login, for a split second you go to the private page, however then you get sent back to the login page.

Hi, @16josephsrgz! :wave:
Glad to know that you have solved some part of your problem :+1:


Can you please post your complete blocks of login screen?

Thanks! :blush:

1 Like

@kartik14 Here you go:


And here are the blocks on the other page:
Screenshot 2020-02-21 at 16.20.45

1 Like

Screenshot 2020-02-21 at 16.20.45

This block, is incorrect - it clearly says, when member page opens, if I am logged in, again open member page.
Do you have a main menu, where all buttons are present? Because, this block should be like -
When member page btn pressed, check login, and navigate accordingly.

Thanks! :blush:

3 Likes

@kartik14 Got it working! Thank you so much, you’re very helpful :). All I had to do was change the member page opens to member page starts! :))

3 Likes