Skip to content

Commit

Permalink
Merge pull request #23 from openfoodfoundation/feataure/admin-team-pa…
Browse files Browse the repository at this point in the history
…ge-update

Updated admin panel and removed team form PAT
  • Loading branch information
ok200paul authored Aug 16, 2024
2 parents 2d8f8e8 + 9438c17 commit e09b9b2
Show file tree
Hide file tree
Showing 48 changed files with 256 additions and 278 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ public function store(): JsonResponse

$user = User::find($userId);

$token = $user->createToken(
name: $name,
abilities: $tokenAbilities,
teamId: $user->current_team_id
);
$token = $user->createToken($name, $tokenAbilities);

$this->message = ApiResponse::RESPONSE_SAVED->value;
$this->data = ['token' => $token->plainTextToken];
Expand Down
16 changes: 0 additions & 16 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use Laravel\Sanctum\NewAccessToken;
use Str;

class User extends Authenticatable
{
Expand Down Expand Up @@ -64,17 +61,4 @@ public function currentTeam(): BelongsTo
{
return $this->belongsTo(Team::class);
}

public function createToken(string $name, array $abilities, int $teamId, ?DateTimeInterface $expiresAt = null): NewAccessToken
{
$token = $this->tokens()->create([
'name' => $name,
'token' => hash('sha256', $plainTextToken = Str::random(40)),
'abilities' => $abilities,
'team_id' => $teamId,
'expires_at' => $expiresAt,
]);

return new NewAccessToken($token, $token->getKey() . '|' . $plainTextToken);
}
}
7 changes: 1 addition & 6 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace App\Providers;

use App\Models\PersonalAccessToken;
use Illuminate\Support\ServiceProvider;
use Laravel\Sanctum\Sanctum;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -16,8 +14,5 @@ public function register(): void {}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
}
public function boot(): void {}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading

0 comments on commit e09b9b2

Please sign in to comment.