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 roundcube#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 16, 2024
1 parent 1e36099 commit 9fc6961
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 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,8 @@ public function login($username, $password, $host = null, $cookiecheck = false)
return false;
}

if ($just_connect) return true;

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

0 comments on commit 9fc6961

Please sign in to comment.