diff options
| author | lsces <lester@lsces.co.uk> | 2025-08-29 13:18:39 +0100 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2025-08-29 13:18:39 +0100 |
| commit | d388cface6a2f2bc7368fa21d8cb6be2e7179f27 (patch) | |
| tree | ef3403eb08c68bc333061f224a61775899a98295 /validate.php | |
| parent | c32ecb5a1051f7c23f25219805af49a348e111c3 (diff) | |
| download | users-d388cface6a2f2bc7368fa21d8cb6be2e7179f27.tar.gz users-d388cface6a2f2bc7368fa21d8cb6be2e7179f27.tar.bz2 users-d388cface6a2f2bc7368fa21d8cb6be2e7179f27.zip | |
General tools updated to PHP8.4 and namespace
Diffstat (limited to 'validate.php')
| -rwxr-xr-x[-rw-r--r--] | validate.php | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/validate.php b/validate.php index 9a068df..ddc5d0a 100644..100755 --- a/validate.php +++ b/validate.php @@ -8,36 +8,42 @@ * @subpackage functions */ + +namespace Bitweaver; +use Bitweaver\KernelTools; +use Bitweaver\Users\BitHybridAuthManager; +use Bitweaver\Users\RolePermUser; +use Bitweaver\Users\UserRepository; + /** * this is a dirty hack to allow admins to log in when we require a visit to the installer * used in kernel/setup_inc.php - xing - Friday Oct 03, 2008 16:44:48 CEST */ -define( 'LOGIN_VALIDATE', TRUE ); +define( 'LOGIN_VALIDATE', true ); /** * required setup */ -require_once( '../kernel/includes/setup_inc.php' ); +require_once '../kernel/includes/setup_inc.php'; global $gBitSystem; -$redirectUrl = FALSE; +$redirectUrl = false; //Remember where user is logging in from and send them back later; using session variable for those of us who use WebISO services //do not use session loginfrom with signin.php or register.php - only "inline" login forms display in perm denied fatals, etc. -if( isset( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/login' ) === FALSE && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/register' ) === FALSE && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/validate' ) === FALSE ) { +if( isset( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/login' ) === false && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/register' ) === false && strpos( $_SERVER['HTTP_REFERER'], USERS_PKG_DIR.'/validate' ) === false ) { $from = parse_url( $_SERVER['HTTP_REFERER'] ); if( $_SERVER['HTTP_HOST'] == $from['host'] ) { // We have a referer from this site, but not an authentication URL $_SESSION['loginfrom'] = (!empty($from['path']) ? $from['path'] : '').( !empty( $from['query'] ) ? '?'.$from['query'] : '' ); } } else { - $_SESSION['loginfrom'] = NULL; - $_SESSION['returnto'] = NULL; + $_SESSION['loginfrom'] = null; + $_SESSION['returnto'] = null; } if( !empty( $_REQUEST['provider'] ) ) { - require_once( USERS_PKG_CLASS_PATH.'BitHybridAuthManager.php' ); BitHybridAuthManager::loadSingleton(); global $gBitHybridAuthManager; @@ -45,60 +51,60 @@ if( !empty( $_REQUEST['provider'] ) ) { if( $gBitUser->isRegistered() ) { $gBitHybridAuthManager->expungeUserProfile( $gBitUser->mUserId, $_REQUEST['provider'] ); } - bit_redirect( $_SESSION['loginfrom'] ); + \Bitweaver\bit_redirect( $_SESSION['loginfrom'] ); } else { try { $auth = $gBitHybridAuthManager->authenticate( $_REQUEST['provider'], $gBitUser ); - if( $auth === FALSE ) { + if( $auth === false ) { // social auth failed - throw new Exception( 'social auth failed' ); - } elseif( $auth === TRUE ) { + throw new \Exception( 'social auth failed' ); + } elseif( $auth === true ) { // account was connected to current object - throw new Exception( 'account was connected to current object' ); + throw new \Exception( 'account was connected to current object' ); } elseif( BitBase::verifyId( $auth ) ) { $redirectUrl = $gBitUser->getPostLoginUrl(); } elseif( is_object( $auth ) && is_a( $auth, 'Hybrid_User_Profile' ) ) { - $_SESSION['returnto'] = NULL; + $_SESSION['returnto'] = null; // an unconnected authProfile was found - $gBitSmarty->assignByRef( 'authProfile', $auth ); + $gBitSmarty->assign( 'authProfile', $auth ); $tpl = 'bitpackage:users/validate_auth.tpl'; if( !empty( $_REQUEST['auth_login'] ) ) { - $user = isset($_REQUEST['user']) ? $_REQUEST['user'] : false; - $pass = isset($_REQUEST['pass']) ? $_REQUEST['pass'] : false; - $challenge = isset($_REQUEST['challenge']) ? $_REQUEST['challenge'] : false; - $response = isset($_REQUEST['response']) ? $_REQUEST['response'] : false; + $user = $_REQUEST['user'] ?? false; + $pass = $_REQUEST['pass'] ?? false; + $challenge = $_REQUEST['challenge'] ?? false; + $response = $_REQUEST['response'] ?? false; // if $referer is set, login() will return the user to whence he came $gBitUser->login( $user, $pass, $challenge, $response ); if( $gBitUser->isRegistered() ) { $gBitHybridAuthManager->storeUserProfile( $gBitUser->mUserId, $_REQUEST['provider'], $auth->identifier, $auth ); $redirectUrl = $gBitUser->getPostLoginUrl(); - $tpl = NULL; + $tpl = null; } else { - $redirectUrl = NULL; + $redirectUrl = null; } } else { if( $gBitUser->isRegistered() ) { $redirectUrl = $gBitUser->getPostLoginUrl(); - $tpl = NULL; + $tpl = null; } elseif( !empty( $_REQUEST['auth_new'] ) && !$gBitUser->isRegistered() ) { - $registerHash = $_REQUEST; - $registerHash['novalidation'] = TRUE; + $pRegisterHash = $_REQUEST; + $pRegisterHash['novalidation'] = true; foreach( array( 'displayName' => 'real_name', 'email'=>'email', 'emailVerified'=>'verified_email', 'gender'=>'customers_gender', 'firstName'=>'customers_firstname', 'lastName'=>'customers_lastname', 'phone'=>'customers_telephone' ) as $member=>$key ) { if( $auth->$member ) { - $registerHash[$key] = $auth->$member; + $pRegisterHash[$key] = $auth->$member; } } if( $auth->birthMonth && $auth->birthDay ) { - $registerHash['customers_dob'] = ($auth->birthYear ? $auth->birthYear : 1900).'-'.$auth->birthMonth.'-'.$auth->birthDay; + $pRegisterHash['customers_dob'] = ($auth->birthYear ? $auth->birthYear : 1900).'-'.$auth->birthMonth.'-'.$auth->birthDay; } $prefId = $gBitHybridAuthManager->getConfigName( $_REQUEST['provider'], 'id' ); $_SESSION['returnto'] = $_SERVER['SCRIPT_URI'].'?provider='.$_REQUEST['provider'].'&auth_login=1'; - include( USERS_PKG_INCLUDE_PATH.'register_inc.php' ); + include USERS_PKG_INCLUDE_PATH.'register_inc.php'; } } } - } catch( Exception $e ) { + } catch( \Exception $e ) { // Display the recived error, // to know more please refer to Exceptions handling section on the userguide switch( $e->getCode() ){ @@ -124,18 +130,18 @@ if( !empty( $_REQUEST['provider'] ) ) { break; } - $gBitSmarty->assignByRef( 'authError', $authError ); - $gBitSmarty->assignByRef( 'authExpection', $e ); + $gBitSmarty->assign( 'authError', $authError ); + $gBitSmarty->assign( 'authExpection', $e ); bit_error_log( $authError ); $tpl = 'bitpackage:users/validate_auth.tpl'; } } } else { - $user = isset($_REQUEST['user']) ? $_REQUEST['user'] : false; - $pass = isset($_REQUEST['pass']) ? $_REQUEST['pass'] : false; - $challenge = isset($_REQUEST['challenge']) ? $_REQUEST['challenge'] : false; - $response = isset($_REQUEST['response']) ? $_REQUEST['response'] : false; + $user = $_REQUEST['user'] ?? false; + $pass = $_REQUEST['pass'] ?? false; + $challenge = $_REQUEST['challenge'] ?? false; + $response = $_REQUEST['response'] ?? false; // if $referer is set, login() will return the user to whence he came $redirectUrl = $gBitUser->login( $user, $pass, $challenge, $response ); @@ -150,6 +156,6 @@ if( !empty( $tpl ) ) { } if( !empty( $redirectUrl ) ) { - bit_redirect( $redirectUrl ); + KernelTools::bit_redirect( $redirectUrl ); } |
