Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: crypto made inline for constructor and decrypt error handled in …
…exception

Signed-off-by: yemkareems <[email protected]>
  • Loading branch information
yemkareems authored and backportbot[bot] committed Oct 28, 2024
commit 1e18546f36ead6437a8e2446b5c1e05371f9358f
13 changes: 7 additions & 6 deletions lib/private/Authentication/LoginCredentials/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
namespace OC\Authentication\LoginCredentials;

use Exception;
use OC\Authentication\Exceptions\PasswordlessTokenException;
use OC\Authentication\Token\IProvider;
use OCP\Authentication\Exceptions\CredentialsUnavailableException;
Expand All @@ -30,17 +31,13 @@ class Store implements IStore {
/** @var IProvider|null */
private $tokenProvider;

/** @var ICrypto */
private $crypto;

public function __construct(ISession $session,
LoggerInterface $logger,
ICrypto $crypto,
private readonly ICrypto $crypto,
?IProvider $tokenProvider = null) {
$this->session = $session;
$this->logger = $logger;
$this->tokenProvider = $tokenProvider;
$this->crypto = $crypto;

Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
}
Expand Down Expand Up @@ -98,7 +95,11 @@ public function getLoginCredentials(): ICredentials {
if ($trySession && $this->session->exists('login_credentials')) {
/** @var array $creds */
$creds = json_decode($this->session->get('login_credentials'), true);
$creds['password'] = $this->crypto->decrypt($creds['password']);
try {
$creds['password'] = $this->crypto->decrypt($creds['password']);
} catch (Exception $e) {
//decryption failed, continue with old password as it is
}
return new Credentials(
$creds['uid'],
$creds['loginName'] ?? $this->session->get('loginname') ?? $creds['uid'], // Pre 20 didn't have a loginName property, hence fall back to the session value and then to the UID
Expand Down