Oauth 2 The email address is not allowed at this site

Oauth 2 The email address is not allowed at this site

by idris alshikh -
Number of replies: 11


hi every one 
Moodle 3.4+ (Build: 20171116)

I'm trying to login with oauth2 service I configure facebook and google I think every thing is ok but  when I try to login  I get this message "The login attempt failed. Reason: The email address is not allowed at this site."


?did any one login with twitter account 

oauth configration





Average of ratings: -
In reply to idris alshikh

Re: Oauth 2 The email address is not allowed at this site

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Did you perhaps limit the domains that can use the log in methods?

In reply to Emma Richardson

إعادة: Re: Oauth 2 The email address is not allowed at this site

by idris alshikh -

hi Emma thank you for your answer

    I think I don't limit any domain if you can point me to particular place to check


In reply to idris alshikh

Re: إعادة: Re: Oauth 2 The email address is not allowed at this site

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Look in your Oauth settings...those look like regular enrollment settings.

Average of ratings: Useful (1)
In reply to Emma Richardson

Re: Oauth 2 The email address is not allowed at this site

by Sarah Ricketts -

There seems to be 2 places that sound similar:

There's the "Allowed email domains : allowemailaddresses" setting:

  • "To restrict new email addresses to particular domains, list them here separated by spaces. All other domains will be rejected. To allow subdomains, add the domain with a preceding '.'. To allow a root domain together with its subdomains, add the domain twice - once with a preceding '.' and once without e.g. .ourcollege.edu.au ourcollege.edu.au."
  • Found at "/admin/settings.php?section=manageauths"

There's also a new 'Login domains' setting:

  • "If set, this setting is a comma separated list of domains that logins will be restricted to when using this provider"
  • Found when setting up OAuth 2 service on 3.3 site.


Do you know the difference between these two settings and would we require the same list of domains in each place?

Kind regards,
Sarah


Average of ratings: Useful (1)
In reply to Sarah Ricketts

Re: Oauth 2 The email address is not allowed at this site

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

The first one is for email based self registration.  The second one is for OAuth login...

Average of ratings: Useful (1)
In reply to Sarah Ricketts

Re: Oauth 2 The email address is not allowed at this site

by Sarah Ricketts -

Thanks Emma.  We had been using the first location for a couple of years when using the OAuth 2 external plugin (before it moved to core) so we will include the same list in both places now.

In reply to idris alshikh

Re: Oauth 2 The email address is not allowed at this site

by Ken Task -
Picture of Particularly helpful Moodlers

Is the 'admin' user you show using the login box for Moodle set in mdl_user table to 'manual'?

That account is/was typically the initial installer (person) of the moodle ... user ID number 2 in mdl_user.

Query that table for id = 2 to see what authentication is set for 'admin' user as well as the EMail address setting for that user.

That user (id 2), BTW, should always remain 'manual'.  IF the other Oauth2's fail for some reason, at least one user still needs to be able to login directly to the moodle or no one will have access.  Also suggest you setup another account using different credentials set to manual and as a member of admin users just in case.

'spirit of sharing', Ken


In reply to Ken Task

إعادة: Re: Oauth 2 The email address is not allowed at this site

by idris alshikh -
I don't limit any domain or email 

  the admin user shows  in browser it's what the browser save user and pass for the site 

I don't have any problem with normal login with admin user   

when I stopped the code checking for is_valid_login_domain everything work fine

the following code cause the problem 


       

        if (!$issuer->is_valid_login_domain($oauthemail)) {

            // Trigger login failed event.

            $failurereason = AUTH_LOGIN_UNAUTHORISED;

            $event = \core\event\user_login_failed::create(['other' => ['username' => $userinfo['username'],

                                                                        'reason' => $failurereason]]);

            $event->trigger();


            $errormsg = get_string('notloggedindebug', 'auth_oauth2', get_string('loginerror_invaliddomain', 'auth_oauth2'));

            $SESSION->loginerrormsg = $errormsg;

            $client->log_out();

            redirect(new moodle_url('/login/index.php'));

        }


In reply to idris alshikh

Re: إعادة: Re: Oauth 2 The email address is not allowed at this site

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

You must have it limited somewhere- make sure you don't have an errant space in either authentication settings or oauth settings.

Average of ratings: Useful (1)
In reply to Emma Richardson

إعادة: Re: إعادة: Re: Oauth 2 The email address is not allowed at this site

by idris alshikh -


thank you Emma sample solution 

can you help me with twitter 

In reply to idris alshikh

Re: إعادة: Re: إعادة: Re: Oauth 2 The email address is not allowed at this site

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

I have never set up twitter authentication but I would imagine it is the same process...