Skip to content

Commit

Permalink
Add flag to avoid setting/creating user on login
Browse files Browse the repository at this point in the history
Fixes #9377 . Allows rcmail::login() to be reused in plugins providing
an API. The login function provides some useful logic for connecting to
IMAP sources like checking credentials for validity or converting
usernames in some cases.

Before this change the login function always also created non-existing
users or set some sesison vars, which what API plugins would like to
avoid.
  • Loading branch information
jaudriga committed Apr 17, 2024
1 parent 7839820 commit 690b364
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions program/include/rcmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -647,14 +647,15 @@ public function session_init()
* Perform login to the mail server and to the webmail service.
* This will also create a new user entry if auto_create_user is configured.
*
* @param string $username Mail storage (IMAP) user name
* @param string $password Mail storage (IMAP) password
* @param string $host Mail storage (IMAP) host
* @param bool $cookiecheck Enables cookie check
* @param string $username Mail storage (IMAP) user name
* @param string $password Mail storage (IMAP) password
* @param string $host Mail storage (IMAP) host
* @param bool $cookiecheck Enables cookie check
* @param bool $just_connect Breaks after successful connect
*
* @return bool True on success, False on failure
*/
public function login($username, $password, $host = null, $cookiecheck = false)
public function login($username, $password, $host = null, $cookiecheck = false, $just_connect = false)
{
$this->login_error = null;

Expand Down Expand Up @@ -773,6 +774,15 @@ public function login($username, $password, $host = null, $cookiecheck = false)
return false;
}

// Only set user if just wanting to connect
if ($just_connect) {
if (is_object($user)) {
$this->set_user($user);
}
return true;
}


// user already registered -> update user's record
if (is_object($user)) {
// update last login timestamp
Expand Down

0 comments on commit 690b364

Please sign in to comment.