devbaji / vue3-google-login

Add Sign In With Google feature to your Vue 3 application
https://github.com/devbaji/vue3-google-login/
MIT License
200 stars 30 forks source link

Close OneTapPopup when loggedIn from another method. #38

Closed Usman-Ejaz closed 1 month ago

Usman-Ejaz commented 1 year ago

I am using OneTapPopup (in main layout file) and Google button (on Login Page).

If I login from Google Login button on Login page. OneTapPopup keep displaying on the top right corner. I want to hide the oneTapPopup when I log in to the application from any other method.

devbaji commented 1 year ago

@Usman-Ejaz If you are using GoogleLogin component, once user is logged in, add any conditional logic to prevent it from rendering, once logged in you don't need to use this component, rendering it will show up On-Tap prompt. Or simply use googleOneTap method which will give you more control when to show up the prompt.

ram-you commented 3 months ago

Hi @devbaji,

Thank you for your response! I appreciate your suggestion to use conditional logic or the googleOneTap method. However, I'm still a bit unclear on how to implement this. Could you please provide a more detailed explanation and a concrete example?

Specifically, I want to understand:

  1. How to use conditional logic to prevent the OneTapPopup from rendering once the user is logged in.
  2. How to use the googleOneTap method to control when the prompt appears and disappears.

Here is my current setup:

Any code snippets or detailed steps would be very helpful.

Thank you!

devbaji commented 1 month ago

@ram-you You might have some state in client side like isLoggedIn or something like that, based on this you need to render the component for example

 <GoogleLogin v-if="!isLoggedIn" :callback="callback" />

This will avoid rendering the component once the user is logged in. Or just only include the component inside your login component rather than the main layout which is shared by all pages.

Or use googleOneTap method, which can be invoked only when needed, maybe inside you onMount logic of login component

I am closing this issue as this is a logic that needed to handled on dev side and not a plugin issue