Skip to content

Commit

Permalink
Add UserBlueprintEvent (#2983)
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncan McClean authored Dec 10, 2020
1 parent 100ae64 commit 7b7a1bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Auth/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Statamic\Contracts\Auth\User;
use Statamic\Contracts\Auth\UserRepository as RepositoryContract;
use Statamic\Events\UserBlueprintFound;
use Statamic\Facades\Blueprint;
use Statamic\OAuth\Provider;

Expand Down Expand Up @@ -47,12 +48,16 @@ public function userGroupRepository()

public function blueprint()
{
return Blueprint::find('user') ?? Blueprint::makeFromFields([
$blueprint = Blueprint::find('user') ?? Blueprint::makeFromFields([
'name' => ['type' => 'text', 'display' => 'Name'],
'email' => ['type' => 'text', 'input_type' => 'email', 'display' => 'Email Address'],
'roles' => ['type' => 'user_roles', 'width' => 50],
'groups' => ['type' => 'user_groups', 'width' => 50],
])->setHandle('user');

UserBlueprintFound::dispatch($blueprint);

return $blueprint;
}

public function findByOAuthId(string $provider, string $id): ?User
Expand Down
13 changes: 13 additions & 0 deletions src/Events/UserBlueprintFound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Statamic\Events;

class UserBlueprintFound extends Event
{
public $blueprint;

public function __construct($blueprint)
{
$this->blueprint = $blueprint;
}
}

0 comments on commit 7b7a1bc

Please sign in to comment.