I’m using social-allauth with microsoft in my django project, but I’m facing some prompem
I have single-tenant(only current organization emails can sign-in in website),
but, I need to filter users while creating it’s table in database.
It means that I want some users to have is_driver=True in user Database (I have custom UserModel) and some of them need to have is_dispatcher=True or is_accountant=True
So, I really don’t get how to do it, how to filter users, is it microsoft part of work I think?
I will use signals for this, but from where should I start from, or where should I set roles and how Can I get them. really can’t figure it out how to do it:
@receiver(social_account_added)
def handle_social_account_added(request, sociallogin, **kwargs):
if sociallogin.account.provider == 'microsoft':
user = sociallogin.account.user
# I need something like this I think
if 'Driver' in roles:
user.is_driver = True
user.is_dispatcher = False
elif 'Dispatcher' in roles:
user.is_driver = False
user.is_dispatcher = True
else:
user.is_driver = False
user.is_dispatcher = False
user.save()