Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 0474c80c authored by Akhil's avatar Akhil
Browse files

Throw exception if user not in SSO database

parent 9b914dcf
Loading
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -123,6 +123,9 @@ class Migrate2FASecrets extends Command {
				$secret = (string) $row['secret'];
				$decryptedSecret = $this->crypto->decrypt($secret);
				$ssoUserId = $this->ssoMapper->getUserId($username, $this->ssoDbConn);
				if(empty($ssoUserId)) {
					throw new Exception('Does not exist in SSO database');
				}
				$entry = $this->getSSOSecretEntry($decryptedSecret, $ssoUserId);
				$this->ssoMapper->insertCredential($entry, $this->ssoDbConn);
			} catch(\Exception $e) {
@@ -139,8 +142,10 @@ class Migrate2FASecrets extends Command {
	 */

	private function getSSOSecretEntry(string $secret, string $ssoUserId) : array {
		// Create the random UUID from the sso user ID so multiple entries of same credential do not happen
		$id = $this->randomUUID(substr($ssoUserId, 0, 16));
		$credentialEntry = [
			'ID' => $this->randomUUID(),
			'ID' => $id,
			'USER_ID' => $ssoUserId,
			'USER_LABEL' => 'Murena Cloud 2FA',
			'TYPE' => 'otp',