Allow social media login to specific user role only

We have been developing an application where we want to allow social media login to only specific role users. below are the scenarios

  1. If the user doesn’t exist and we have been trying social media login with that user id, then it will create a new entry for that user,so keycloak already supported this feature and we can also assign default roles for that using realm role/ client role default role setting.
  2. but what if the user is already exist that you have entered using social media login, then we want authentication check for role. for example we want social media login only for “Student” role , not for other roles.
    If any one knows how to implement this then kindly help.