Also, I donāt know if you could help me with another question please? In user auth table there is email and primary_email. Is the logic that email is used for the login and primary_email is a field in-case they want alerts to go to a different email that their login email so you can store 2 separate email addresses? I couldnāt find any mention of it in docs.
We had this issue a while back. We required users to have an email and therefore rejected users whose email was not provided with the following check when adding the facebook auth plugin:
Iām not sure how this can be tested programmatically but manually: as a Facebook user you can edit and decline certain permissions. Decline āemailā permission on the Facebookās login/sign/consent up flow page. Hereās a link to Facebookās dev docs to how testing might be bit easier.
When a user declines āemailā, they can then be redirected to a url of your choice(with a friendly message of why their request was declined) by simply returning:
return authCtx.Service.Redirect(urlOfYourChoice);
This will also work for existing users, i.e the ones that are already in your system without emails. They will be taken to the same redirected url.
@kebin
This works. But do you know (by any chance) if there is a way to display the Facebook login screen again (via the redirect) of maybe remove the app permissions automatically?
At the moment I show a āhow toā to the user, but this is far from idealā¦
private IHttpResult FacebookCustomValidator(AuthContext authCtx)
{
if (authCtx.AuthTokens.Email.IsEmpty())
{
var redirectUrl = FacebookAuthProvider.PreAuthUrl
.AddQueryParam("scope", "email")
.AddQueryParam("auth_type", "rerequest")
.AddQueryParam("client_id", "YOUR_APP_ID")
.AddQueryParam("redirect_uri", new RequestObjectTeRedirectTo().ToAbsoluteUri());
// first redirect to the login page to explain what happened and show the redirectUrl on that page
var loginUrl = new LoginRequest { Platform = "facebook", Redirect = redirectUrl, RequireEmail = true };
return authCtx.Service.Redirect(loginUrl.ToAbsoluteUri());
}
return null;
}