rtCamp / login-with-google

Minimal plugin which allows WordPress user to login with google.
https://wordpress.org/plugins/login-with-google/
GNU General Public License v2.0
57 stars 17 forks source link

Customized user authentication function #137

Open ravid007 opened 1 year ago

ravid007 commented 1 year ago

Hi, I would like to add my own function for user authentication in the middle of the flow, right after the authentication with google and before the user is registered or signed in if he already exists. Is it possible to use the rtcamp.google_user_authenticated hook somehow to stop the flow and prevent from creating a user or sign-in a user? Of course I prefer to use hooks (filters) and not to make any changes in the code of the plugin. If that's not possible, I'd be happy to add it as a feature request. Thanks!

elifvish commented 1 year ago

@ravid007 rtcamp.google_user_authenticated hook can be used to obstruct the flow for user login. User creation however cannot be obstructed using this hook. You can use this hook rtcamp.google_user_created which is fired after user data insertion. To add additional functionality or checks for user creation.

ravid007 commented 1 year ago

@elifvish If I understand correctly, the rtcamp.google_user_created hook is fired after the user has been already created and registered successfully. Isn't that too late for additional functionality and checks for user creation? I want to decide whether to create the user or not based on his email address.

elifvish commented 1 year ago

@ravid007 If your goal is to allow user registration from specific domains (domain in email) you can add domains you want to whitelist in Whitelisted Domains field in settings page.

ravid007 commented 1 year ago

@elifvish I am familiar with that cool functionality, but unfortunately the login authentication is based on a list of specific Gmail address from a DB server. I'm pretty sure that the correct place for authentication functionality is the rtcamp.google_user_authenticated hook by returning a Boolean TRUE/FALSE value for commence the registration or break it. I think It can be a very nice and useful feature for this plugin.

ravid007 commented 1 year ago

@elifvish @aviral-mittal Could you please consider adding this feature in next release please? that will be very helpful. Thanks.

aviral-mittal commented 1 year ago

@ravid007 We have not yet finalised adding this in next release, however, we will consider. We will update this issue with whatever decision we go ahead with. Hope you continue to enjoy using the plugin. :)