Skip to content

Commit

Permalink
Add provider to user model (#14625)
Browse files Browse the repository at this point in the history
* Add provider to user model

* Update install.sql to changes in code

* Add conditional check to adding column in migration file

* Update models/User.php

---------

Co-authored-by: Divesh Pahuja <divesh.pahuja@pimcore.com>
  • Loading branch information
svdv22 and dvesh3 committed Mar 14, 2023
1 parent 671a08b commit f636357
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
38 changes: 38 additions & 0 deletions bundles/CoreBundle/Migrations/Version20230223101848.php
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\CoreBundle\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20230223101848 extends AbstractMigration
{
public function up(Schema $schema): void
{
if (!$schema->getTable('users')->hasColumn('provider')) {
$this->addSql('ALTER TABLE `users` ADD COLUMN `provider` varchar(255) DEFAULT NULL;');
}
}

public function down(Schema $schema): void
{
if ($schema->getTable('users')->hasColumn('provider')) {
$this->addSql('ALTER TABLE `users` DROP COLUMN `provider`;');
}
}
}
1 change: 1 addition & 0 deletions bundles/InstallBundle/Resources/install.sql
Expand Up @@ -646,6 +646,7 @@ CREATE TABLE `users` (
`docTypes` text DEFAULT NULL,
`classes` text DEFAULT NULL,
`twoFactorAuthentication` varchar(255) DEFAULT NULL,
`provider` varchar(255) DEFAULT NULL,
`activePerspective` VARCHAR(255) NULL DEFAULT NULL,
`perspectives` LONGTEXT NULL DEFAULT NULL,
`websiteTranslationLanguagesEdit` LONGTEXT NULL DEFAULT NULL,
Expand Down
15 changes: 15 additions & 0 deletions models/User.php
Expand Up @@ -132,6 +132,11 @@ final class User extends User\UserRole
*/
protected $twoFactorAuthentication;

/**
* OIDC Provider from pimcore/openid-connect
*/
protected ?string $provider = null;

/**
* @return string|null
*/
Expand Down Expand Up @@ -1064,6 +1069,16 @@ public function setTwoFactorAuthentication($key, $value = null)
}
}

public function getProvider(): ?string
{
return $this->provider;
}

public function setProvider(?string $provider): void
{
$this->provider = $provider;
}

public function hasImage()
{
return Tool\Storage::get('admin')->fileExists($this->getOriginalImageStoragePath());
Expand Down

0 comments on commit f636357

Please sign in to comment.