예제 #1
0
/**
 * Perform any post-login operations
 *
 * Checks if the user has been protected by an earlier
 * version of the Rublon plugin
 *
 * @param string $user_login
 * @param WP_User $user
 */
function rublon2factor_wp_login($user_login, $user)
{
    if (RublonHelper::isUserSecured($user) && !RublonHelper::isUserAuthenticated($user)) {
        $msg_meta = get_user_meta(RublonHelper::getUserId($user), RublonHelper::RUBLON_META_AUTH_CHANGED_MSG, true);
        if ($msg_meta === '') {
            $msg_meta = -1;
        } else {
            $msg_meta = (int) $msg_meta;
        }
        if ($msg_meta > 8) {
            delete_user_meta(RublonHelper::getUserId($user), RublonHelper::RUBLON_META_AUTH_CHANGED_MSG);
            RublonHelper::disconnectRublon2Factor($user);
        } else {
            $msg_meta++;
            if ($msg_meta % 3 == 0) {
                RublonHelper::setMessage('AUTHENTICATION_TYPE_CHANGED', 'updated', 'POSTL');
            }
            update_user_meta(RublonHelper::getUserId($user), RublonHelper::RUBLON_META_AUTH_CHANGED_MSG, $msg_meta);
        }
    }
}