Skip to content

Commit

Permalink
Improve auth_prepare_username to use in login
Browse files Browse the repository at this point in the history
  • Loading branch information
vboctor committed Apr 16, 2017
1 parent 9734b15 commit 5f26bfb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions core/authentication_api.php
Expand Up @@ -311,28 +311,32 @@ function auth_is_user_authenticated() {
* @access public
*/
function auth_prepare_username( $p_username ) {
$t_username = null;

switch( config_get( 'login_method' ) ) {
case BASIC_AUTH:
$f_username = $_SERVER['REMOTE_USER'];
$t_username = $_SERVER['REMOTE_USER'];
break;
case HTTP_AUTH:
if( !auth_http_is_logout_pending() ) {
if( isset( $_SERVER['PHP_AUTH_USER'] ) ) {
$f_username = $_SERVER['PHP_AUTH_USER'];
$t_username = $_SERVER['PHP_AUTH_USER'];
}
} else {
auth_http_set_logout_pending( false );
auth_http_prompt();

# calls exit
return null;
}
break;
default:
$f_username = $p_username;
$t_username = $p_username;
break;
}
return $f_username;

if( !is_null( $t_username ) ) {
$t_username = user_is_name_valid( $t_username ) ? $t_username : null;
}

return $t_username;
}

/**
Expand Down

0 comments on commit 5f26bfb

Please sign in to comment.