Plugin Directory

Changeset 2201878


Ignore:
Timestamp:
11/27/2019 09:31:13 AM (6 years ago)
Author:
wpintegrate
Message:

Added option for Redirect after login

Location:
o365-user-authentication/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • o365-user-authentication/trunk/function/o365_azure_login_settings.php

    r2176874 r2201878  
    130130                        wp_register_script( 'o365_user_auth_script', O365_USER_AUTH_ONLINE_PLUGIN_URL. '/assests/js/o365_user_auth.js' );
    131131                        wp_localize_script(  'o365_user_auth_script', 'o365_user_auth_script_obj', $value_array );
    132                         wp_enqueue_script( 'o365_user_auth_script' );
     132                        wp_enqueue_script( 'o365_user_auth_script' );                   
    133133                ?>
    134134               
    135135           
    136                
     136                <tr class="form-field">
     137                      <th> <label>Redirect after login</label>  </th>
     138                      <td>
     139                        <input type="radio" name="o365_user_auth_redirect_after_login" value="admin_dashboard" checked/> Admin Dashboard <br/>
     140                        <input type="radio" name="o365_user_auth_redirect_after_login" value="current_page" <?php if($azure_login_setting_flow->after_login_redirect_url == 'current_page'){echo 'checked';} ?>/> Current Page
     141                      </td>
     142                </tr>       
    137143               
    138144       
  • o365-user-authentication/trunk/inc/o365_user_auth_online_class.php

    r1963459 r2201878  
    7474                $azure_login_setting_flow = json_decode( $azure_login_setting_flow );
    7575                $value = $azure_login_setting_flow->azure_print_login_link;
     76                if(session_status() === PHP_SESSION_NONE){ session_start(); }
     77                $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
     78                $currenturl =   $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     79                if( !strstr($currenturl, 'wp-login.php') ){
     80                    unset($_SESSION['currentpageurl']);     
     81                    $_SESSION['currentpageurl'] = $currenturl;
     82                }
     83
    7684                if( $value == "Yes" || $value == "" )
    7785                {
     
    107115                        'login_text' => '',
    108116                        'image_url' => '',
    109                     ), $atts, 'o365_azure_login_url' 
     117                    ), $atts, 'o365_azure_login_url'
    110118                );
    111119            if( isset($atts["login_text"]) && $atts["login_text"] !="" )
     
    131139    function o365_user_auth_authenticate( $user, $username, $password )
    132140    {
    133         // Don't re-authenticate if already authenticated
     141        /* Don't re-authenticate if already authenticated */
    134142        if ( is_a( $user, 'WP_User' ) ) {
    135143            return $user;
    136144        }
    137145        if ( isset( $_GET['code'] ) ) {
    138             //$antiforgery_id = $_SESSION[ self::ANTIFORGERY_ID_KEY ];
     146            /* $antiforgery_id = $_SESSION[ self::ANTIFORGERY_ID_KEY ]; */
    139147            $antiforgery_id = sanitize_text_field($_GET['state']);
    140148            $state_is_missing = !isset( $_GET['state']);
    141149            $state_doesnt_match = sanitize_text_field($_GET['state']) != $antiforgery_id;
    142             // Looks like we got an authorization code, let's try to get an access token with it
     150            /* Looks like we got an authorization code, let's try to get an access token with it */
    143151            $acc_code = sanitize_text_field($_GET['code']);
    144152            $token = O365_USER_AUTH_ONLINE_AuthorizationHelper::getAccessToken( $acc_code, $this->settings );
    145             // Happy path
     153            /* Happy path */
    146154            if ( isset( $token->access_token ) ) {
    147155                try {
     
    157165                    );
    158166                }
    159                 // Invoke any configured matching and auto-provisioning strategy and get the user.
     167                /* Invoke any configured matching and auto-provisioning strategy and get the user. */
    160168                $user = $this->getWPUserFromAADUser( $o365_online_JWT );
    161169            } elseif ( isset( $token->error ) ) {
    162                 // Unable to get an access token (although we did get an authorization code)
     170                /* Unable to get an access token (although we did get an authorization code) */
    163171                return new WP_Error(
    164172                    $token->error,
     
    169177                );
    170178            } else {
    171                 // None of the above, I have no idea what happened.
     179                /* None of the above, I have no idea what happened. */
    172180                return new WP_Error( 'unknown', 'ERROR: An unknown error occured.' );
    173181            }
    174182        } elseif ( isset( $_GET['error'] ) ) {
    175             // The attempt to get an authorization code failed.
     183            /* The attempt to get an authorization code failed. */
    176184            return new WP_Error(
    177185                sanitize_text_field($_GET['error']),
     
    263271                        );
    264272                    }
    265                     $o365_user_auth_redirect_to = get_site_url()."/wp-admin";
     273
     274                    $o365_user_auth_redirect_to = '';
     275
     276                    if( $azure_login_setting_flow->after_login_redirect_url == 'current_page' ){
     277                        $o365_user_auth_redirect_to = $_SESSION['currentpageurl'];
     278                    }
     279                    if(empty($o365_user_auth_redirect_to)){
     280                        $o365_user_auth_redirect_to = get_site_url()."/wp-admin";
     281                    }
     282
    266283                    $o365_user_auth_new_assign_role = "subscriber";
    267284                    /** Get user by user meta aaduserobjectid: Start**/
     
    413430                $azure_login_setting_flow = json_decode( $azure_login_setting_flow );
    414431                $value = $azure_login_setting_flow->azure_print_login_link;
     432                if(session_status() === PHP_SESSION_NONE){ session_start(); }
     433                $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
     434                $currenturl =   $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     435                if( !strstr($currenturl, 'wp-login.php') ){
     436                    unset($_SESSION['currentpageurl']);     
     437                    $_SESSION['currentpageurl'] = $currenturl;
     438                }
     439
    415440                if( $value == "Yes" || $value == "" ){
    416441                if( isset( $azure_login_setting_flow->azure_image_login_link ) && $azure_login_setting_flow->azure_image_login_link !="" ){
  • o365-user-authentication/trunk/o365-user-auth-online.php

    r2183104 r2201878  
    33 * Plugin Name: Office 365 User Authentication
    44 * Plugin URI:  http://www.wpintegrate.com/
    5  * Version:     1.3
     5 * Version:     1.5
    66 * Author:      wpintegrate.com
    77 * Author URI:  wpintegrate.com
  • o365-user-authentication/trunk/readme.txt

    r2177016 r2201878  
    66Tested up to: 5.2.4
    77Requires PHP: 5.6.36
    8 Stable tag: 1.4
     8Stable tag: 1.5
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    152152Make it compatible to PHP 7 and WordPress 5.2.4
    153153
     154= 1.5 =
     155Added option for Redirect after login
     156
    154157== Upgrade Notice ==
    155158
Note: See TracChangeset for help on using the changeset viewer.