Google Sign on and User_CustomValidate

Hi everyone!

This may be a simple question but this is the first time I am dealing with the User_CustomValidate function and “Google Sing on”.

My “users” table has the following fields: “user”, “password”, “mail” and “userlevel”. I understand that if I use Google Sign on what comes back to me after a user is identified with his mail I get this a username.

PHP support tells me that the only thing I have to do is to map that email in the user table but I don’t know how to do it. I guess I would have to do something like this:

function User_CustomValidate(string &$userName): bool
{
if (IsAccessTokenUser()) {
$userName = ExecuteQuery("SELECT user FROM users WHERE email = '$userName"");
}
return false;
}

Is this approach correct? Thanks

Are you talking about Google Single Sign-On with SAML? If yes, please read the documentation:

Single Sign-On with SAML

Basically, you only need on create the same userid,email that u login with SSO and grant the permission accordingly. Once authenticate, it should log you in automatically if the user existed in the system.

Also refer to this thread

Great. Thank you so much! I took some ideas from that thread and now it works. This is the function I’m currently using:

function User_CustomValidate(string &$userName): bool
{
if (IsAccessTokenUser()) {
$user = ExecuteScalar("SELECT cod_user FROM ALUMNO WHERE email = '$userName'");
    if($user){
    $userName = $user; return true;
    }
}
return false;
}

1 Like