"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mrbs-1.9.4/web/lib/MRBS/Session/SessionWordpress.php" between
mrbs-1.9.4.tar.gz and mrbs-1.10.0.tar.gz

About: MRBS is a web application for booking meeting rooms or other resources (using PHP and MySQL/pgsql).

SessionWordpress.php  (mrbs-1.9.4):SessionWordpress.php  (mrbs-1.10.0)
<?php <?php
namespace MRBS\Session; namespace MRBS\Session;
use MRBS\User;
require_once MRBS_ROOT . '/auth/cms/wordpress.inc'; require_once MRBS_ROOT . '/auth/cms/wordpress.inc';
class SessionWordpress extends SessionWithLogin class SessionWordpress extends SessionWithLogin
{ {
public function __construct() public function __construct()
{ {
$this->checkTypeMatchesSession(); $this->checkTypeMatchesSession();
parent::__construct(); parent::__construct();
} }
public function getCurrentUser() public function getCurrentUser() : ?User
{ {
if (!is_user_logged_in()) if (!is_user_logged_in())
{ {
return null; return null;
} }
$mrbs_user = wp_get_current_user(); $mrbs_user = wp_get_current_user();
return \MRBS\auth()->getUser($mrbs_user->user_login); return \MRBS\auth()->getUser($mrbs_user->user_login);
} }
// Can only return a valid username. If the username and password are not val id it will ask for new ones. // Can only return a valid username. If the username and password are not val id it will ask for new ones.
protected function getValidUser($username, $password) protected function getValidUser(?string $username, ?string $password) : string
{ {
global $errors; // $errors is a WordPress global global $errors; // $errors is a WordPress global
$credentials = array(); $credentials = array();
$credentials['user_login'] = $username; $credentials['user_login'] = $username;
$credentials['user_password'] = $password; $credentials['user_password'] = $password;
$credentials['remember'] = false; $credentials['remember'] = false;
$wp_user = wp_signon($credentials); $wp_user = wp_signon($credentials);
if (is_wp_error($wp_user)) if (is_wp_error($wp_user))
skipping to change at line 50 skipping to change at line 52
$errors = $wp_user; $errors = $wp_user;
$error_message = apply_filters('login_errors', $wp_user->get_error_message ()); $error_message = apply_filters('login_errors', $wp_user->get_error_message ());
// The Wordpress error message contains HTML so don't escape it. // The Wordpress error message contains HTML so don't escape it.
$this->authGet($this->form['target_url'], $this->form['returl'], $error_me ssage, $raw=true); $this->authGet($this->form['target_url'], $this->form['returl'], $error_me ssage, $raw=true);
exit(); // unnecessary because authGet() exits, but just included for clar ity exit(); // unnecessary because authGet() exits, but just included for clar ity
} }
return $username; return $username;
} }
protected function logonUser($username) protected function logonUser(string $username) : void
{ {
// Don't need to do anything: the user will have been logged on when the // Don't need to do anything: the user will have been logged on when the
// username and password were validated. // username and password were validated.
} }
public function logoffUser() public function logoffUser() : void
{ {
wp_logout(); wp_logout();
} }
} }
 End of changes. 5 change blocks. 
4 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)