Plugin Directory

Changeset 1740355


Ignore:
Timestamp:
10/03/2017 02:00:03 PM (9 years ago)
Author:
unloqer
Message:
  • Fixed an issue with login redirect
Location:
unloq/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • unloq/trunk/autoloader/class-utility.php

    r1735499 r1740355  
    6969        array_push($_SESSION[self::UNLOQ_FLASH_KEY], $item);
    7070        return true;
     71    }
     72
     73    /*
     74     * Clears the UNLOQ flash for errors.
     75     * */
     76    public static function clearFlash() {
     77        if(isset($_SESSION[self::UNLOQ_FLASH_KEY])) {
     78            $_SESSION[self::UNLOQ_FLASH_KEY] = array();
     79        }
    7180    }
    7281
  • unloq/trunk/autoloader/login/class-login.php

    r1735499 r1740355  
    10491049            session_start();
    10501050        }
    1051         add_action('init', array($this, "sso_request_start"), 1);
    1052     }
    1053 
    1054     private function sso_request_login() {
     1051        add_action('init', array($this, "sso_request_start"), 2);
     1052        add_action('init', array($this, "sso_request_login"), 0);
     1053    }
     1054
     1055
     1056    public function sso_request_login() {
    10551057        if(!isset($_GET['unloq_uauth']) || !isset($_GET['token']) || !strlen($_GET['token'])) return;
    10561058        if($_GET['unloq_uauth'] !== 'login') return;
    10571059        $token = $_GET['token'];
    1058 
    10591060        $isLogged = $this->consume_token($token);
    10601061        if($isLogged !== true) {
     
    10641065        }
    10651066        parse_str($this->utility->rgar($_GET, 'query'), $query);
    1066 
    10671067        $redirect_to = apply_filters('uq_login_redirect', $this->utility->rgar($query, 'redirect_to', admin_url('index.php')));
    10681068        wp_redirect($redirect_to);
     
    10761076    public function sso_request_start() {
    10771077        if(is_admin()) return;
    1078         $this->sso_request_login();
    10791078        if(!isset($GLOBALS['pagenow']) || $GLOBALS['pagenow'] !== 'wp-login.php') return;
    10801079        wp_enqueue_script( 'uq-login-compat', UQ_VENDORS . '/ui/js/login.compat.js', array('jquery'), UQ_VERSION, true );
     
    11521151            }
    11531152        }
     1153        $this->utility->clearFlash();
    11541154        return $errors;
    11551155    }
  • unloq/trunk/autoloader/login/login.tpl.php

    r1735499 r1740355  
    1717                    redirUrl += 'unloq_uauth=login&token=' + data.token;
    1818                    try {
    19                       window.location = redirUrl;
     19                      window.location.replace(redirUrl);
    2020                    } catch(e) {
     21                      window.location.href = redirUrl;
    2122                    }
    22                     setTimeout(function() {
    23                       try {
    24                         window.location.replace(redirUrl);
    25                       } catch(e) {
    26                       }
    27                     }, 5);
    2823                });
    2924            })();
  • unloq/trunk/readme.txt

    r1736178 r1740355  
    119119
    120120== Changelog ==
     121= 2.1.4 =
     122* Fixed an issue with login redirect
    121123= 2.1.3 =
    122124* Fixed an issue with class autoloader
  • unloq/trunk/unloq.php

    r1736178 r1740355  
    33 * Plugin Name:       UNLOQ Authentication
    44 * Description:       Perform UNLOQ.io authentications with the click of a button
    5  * Version:           2.1.3
     5 * Version:           2.1.4
    66 * Author:            UNLOQ.io
    77 * Author URI:        https://unloq.io
  • unloq/trunk/vendors/ui/js/login.compat.js

    r1735499 r1740355  
    2929    document.getElementsByTagName('head')[0].appendChild(script);
    3030  }
     31
    3132  function loadPlugin($) {
    3233    var $btn = $("#btnInitUnloq");
    33     if(!$btn || $btn.size() === 0) return;  // unloq-only.
     34    if (!$btn || $btn.size() === 0) return;  // unloq-only.
    3435    var $login = $("#login"),
    3536      $form = $login.find("form").first();
    36     if($login.size() === 0) {
     37    if ($login.size() === 0) {
    3738      // something went wrong.
    3839      console.error('UNLOQ Failed to initialize, the login form was no-where to be found.');
     
    6364      isInitialized = true;
    6465      $scr.load(function() {
    65         if(typeof window.UNLOQ !== 'object' || !window.UNLOQ) return;
    66         if(typeof window.UNLOQ.onLogin !== 'function') return;
     66        if (typeof window.UNLOQ !== 'object' || !window.UNLOQ) return;
     67        if (typeof window.UNLOQ.onLogin !== 'function') return;
    6768        // Manually handle the redirect, to avoid issues with token and redirect loops.
    6869        window.UNLOQ.onLogin(function(data) {
    69           if(typeof data !== 'object' || !data) return;
    70           if(typeof data.token !== 'string' || !data.token) return;
     70          if (typeof data !== 'object' || !data) return;
     71          if (typeof data.token !== 'string' || !data.token) return;
    7172          var redirUrl = window.location.href.split('#')[0];
    7273          redirUrl += (redirUrl.indexOf('?') === -1 ? '?' : '&');
    7374          redirUrl += 'unloq_uauth=login&token=' + data.token;
    7475          try {
    75             window.location = redirUrl;
     76            window.location.replace(redirUrl);
    7677          } catch(e) {
     78            window.location.href = redirUrl;
    7779          }
    78           setTimeout(function() {
    79             try {
    80               window.location.replace(redirUrl);
    81             } catch(e) {
    82             }
    83           }, 5);
    8480        });
    8581      });
     
    8985      var which = ($(this).hasClass('tab-unloq') ? 'unloq' : 'password'),
    9086        $parent = $(this).parent();
    91       if(which == 'unloq') {
    92         if($parent.hasClass('password-active')) {
     87      if (which == 'unloq') {
     88        if ($parent.hasClass('password-active')) {
    9389          $parent.removeClass('password-active');
    9490        }
    95         if($parent.hasClass('unloq-active')) return;
     91        if ($parent.hasClass('unloq-active')) return;
    9692        $parent.addClass('unloq-active');
    97         if(isInitialized) return;
     93        if (isInitialized) return;
    9894        initialize();
    9995      } else {
    100         if($parent.hasClass('unloq-active')) {
     96        if ($parent.hasClass('unloq-active')) {
    10197          $parent.removeClass('unloq-active');
    10298        }
    103         if($parent.hasClass('password-active')) return;
     99        if ($parent.hasClass('password-active')) return;
    104100        $parent.addClass('password-active');
    105101      }
     
    107103
    108104    $tabs.on('click touchstart', '> .tab', onChange);
    109     if($tabs.hasClass('unloq-active')) {
     105    if ($tabs.hasClass('unloq-active')) {
    110106      initialize();
    111107    }
Note: See TracChangeset for help on using the changeset viewer.