def create_session(user):
    """
    Create the login session 
    :param user: UserModel
    :return:
    """

    def cb():
        if user:
            if __options__.get("require_email_verification") and not user.email_verified:
                raise exceptions.VerifyEmailError()
            if flask_login.login_user(user):
                user.update(last_login_at=utc_now())
                return user
        return None

    return signals.user_login(cb)