<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def post_user_login(sender, request, user, **kwargs):
 """ Create a profile for the user, when missing. Make sure that all neccessary user groups exist and have the right permissions. We need that automatism for people not calling the configure tool, admin rights for admins after the first login, and similar cases. """

    logger.debug("Running post-processing for user login.")
    # Users created by social login or admins have no profile.
    # We fix that during their first login.
    try:
        with transaction.atomic():
            profile, created = UserProfile.objects.get_or_create(user=user)
            if created:
                logger.info("Created missing profile for user " + str(user.pk))
    except Exception as e:
        logger.error("Error while creating user profile: " + str(e))
    check_permission_system()