Skip to content

Commit

Permalink
Style fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
danidou committed Apr 10, 2024
1 parent 2b0cee3 commit 1b387c4
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 49 deletions.
6 changes: 3 additions & 3 deletions config/badgefactor2.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

return [
'domain' => env('BF2_DOMAIN_NAME', null),
'domain' => env('BF2_DOMAIN_NAME', null),
'cache_duration' => env('BF2_CACHE_DURATION', 86400),
'encryption' => [
'encryption' => [
'algorithm' => env('BF2_ENCRYPTION_ALGORITHM'),
'secret_key' => env('BF2_SECRET_KEY'),
'secret_iv' => env('BF2_SECRET_IV'),
Expand All @@ -24,7 +24,7 @@
'badgr' => [
'server_url' => env('BADGR_SERVER_URL'),
'admin_scopes' => 'rw:backpack rw:profile rw:issuer rw:serverAdmin',
'personal_scopes' => 'rw:backpack rw:profile'
'personal_scopes' => 'rw:backpack rw:profile',
],
'user_model' => env('BF2_USER_MODEL', \Ctrlweb\BadgeFactor2\Models\User::class),
'search_controller' => env('BF2_SEARCH_CONTROLLER', \Ctrlweb\BadgeFactor2\Http\Controllers\Api\SearchController::class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
return new class() extends Migration {
/**
* Run the migrations.
*
Expand Down
1 change: 0 additions & 1 deletion src/Events/EmailChangeRequested.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ class EmailChangeRequested
public function __construct(public User $user)
{
}

}
2 changes: 0 additions & 2 deletions src/Events/EmailChangeValidated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Ctrlweb\BadgeFactor2\Events;

use Ctrlweb\BadgeFactor2\Models\User;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
Expand All @@ -21,5 +20,4 @@ class EmailChangeValidated
public function __construct(public int $userId, public string $oldEmail, public string $newEmail)
{
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public function toggleVisibility(AssertionVisibilityRequest $request, string $en

$assertionVisibility = AssertionUser::updateOrCreate(
[
'user_id' => $request->user()->id,
'user_id' => $request->user()->id,
'assertion_id' => $entityId,
],
[
'is_visible' => $request->input('is_visible')
'is_visible' => $request->input('is_visible'),
]
);

Expand All @@ -52,7 +52,7 @@ public function toggleVisibility(AssertionVisibilityRequest $request, string $en
}

return response()->json([
'success' => true,
'success' => true,
'assertion' => AssertionUserResource::make($assertionVisibility),
]);
}
Expand Down
30 changes: 15 additions & 15 deletions src/Http/Resources/Badgr/AssertionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ public function toArray($request)
'issuer' => $this['issuer'],
'image' => $this['image'],
'recipient' => [
'slug' => null,
'username' => null,
'first_name' => 'Utilisateur',
'last_name' => 'Anonyme',
'description' => null,
'website' => null,
'establishment' => null,
'place' => null,
'organisation' => null,
'job' => null,
'biography' => null,
'facebook' => null,
'twitter' => null,
'linkedin' => null,
'photo' => null,
'slug' => null,
'username' => null,
'first_name' => 'Utilisateur',
'last_name' => 'Anonyme',
'description' => null,
'website' => null,
'establishment' => null,
'place' => null,
'organisation' => null,
'job' => null,
'biography' => null,
'facebook' => null,
'twitter' => null,
'linkedin' => null,
'photo' => null,
'last_connexion' => null,
]
];
Expand Down
2 changes: 0 additions & 2 deletions src/Http/Resources/Badgr/AssertionUserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Ctrlweb\BadgeFactor2\Http\Resources\Badgr;

use App\Http\Resources\LearnerPublicResource;
use Ctrlweb\BadgeFactor2\Models\User;
use Illuminate\Http\Resources\Json\JsonResource;

class AssertionUserResource extends JsonResource
Expand Down
1 change: 1 addition & 0 deletions src/Listeners/SendEmailChangeConfirmationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class SendEmailChangeConfirmationRequest implements ShouldQueue
* Handle the event.
*
* @param object $event
*
* @return void
*/
public function handle(EmailChangeRequested $event)
Expand Down
17 changes: 8 additions & 9 deletions src/Listeners/UpdateEmailInExternalSystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
use Ctrlweb\BadgeFactor2\Events\EmailChangeValidated;
use Ctrlweb\BadgeFactor2\Models\User;
use Ctrlweb\BadgeFactor2\Services\Badgr\BackpackAssertion;
use Ctrlweb\BadgeFactor2\Services\Badgr\User as BadgrUser;
use Hautelook\Phpass\PasswordHash;
use Illuminate\Auth\Events\Attempting;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

Expand Down Expand Up @@ -39,10 +35,11 @@ private function inBadgr(int $userId, string $oldEmail, string $newEmail): void
$badgrUser = array_pop($badgrUser);

// Update Badgr user.
$rowsAffected = $badgrDb->update('update users set email = ? where id = ?',
$rowsAffected = $badgrDb->update(
'update users set email = ? where id = ?',
[
$newEmail,
$badgrUser->id
$badgrUser->id,
]
);
if ($rowsAffected === 0) {
Expand All @@ -54,10 +51,11 @@ private function inBadgr(int $userId, string $oldEmail, string $newEmail): void
}

// Update Badgr account email address.
$rowsAffected = $badgrDb->update('update account_emailaddress set email = ?, verified = true where user_id = ?',
$rowsAffected = $badgrDb->update(
'update account_emailaddress set email = ?, verified = true where user_id = ?',
[
$newEmail,
$badgrUser->id
$badgrUser->id,
]
);
if ($rowsAffected === 0) {
Expand All @@ -69,7 +67,8 @@ private function inBadgr(int $userId, string $oldEmail, string $newEmail): void
}

// Reassign Badgr badge instances.
$rowsAffected = $badgrDb->update('update issuer_badgeinstance set recipient_identifier = ? where recipient_identifier = ?',
$rowsAffected = $badgrDb->update(
'update issuer_badgeinstance set recipient_identifier = ? where recipient_identifier = ?',
[
$newEmail,
$oldEmail,
Expand Down
6 changes: 1 addition & 5 deletions src/Models/Badgr/AssertionUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

namespace Ctrlweb\BadgeFactor2\Models\Badgr;

use Ctrlweb\BadgeFactor2\Events\AssertionIssued;
use Ctrlweb\BadgeFactor2\Models\User;
use Ctrlweb\BadgeFactor2\Services\Badgr\Assertion as BadgrAssertion;
use Ctrlweb\BadgeFactor2\Services\Badgr\BackpackAssertion;
use Illuminate\Database\Eloquent\Model;

class AssertionUser extends Model
Expand All @@ -14,7 +10,7 @@ class AssertionUser extends Model
protected $table = 'assertion_user';

protected $casts = [
'user_id' => 'integer',
'user_id' => 'integer',
'is_visible' => 'boolean',
];

Expand Down
11 changes: 7 additions & 4 deletions src/Notifications/ChangeEmailNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ChangeEmailNotification extends Notification
* Get the notification's channels.
*
* @param mixed $notifiable
*
* @return array|string
*/
public function via($notifiable)
Expand All @@ -31,20 +32,22 @@ public function via($notifiable)
* Build the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$oldEstablishment = Establishment::find($notifiable->establishment_id);
$newEstablishment = Establishment::find($notifiable->new_establishment_id);

return (new MailMessage)
->subject(config('app.name').' - Confirmation de changement d\'adresse courriel')
->from(config('cadre21.mail.default_sender'))
->markdown('notifications.email-change', [
'old_email' => $notifiable->email,
'new_email' => $notifiable->new_email,
'old_job' => $notifiable->job,
'new_job' => $notifiable->new_job,
'old_email' => $notifiable->email,
'new_email' => $notifiable->new_email,
'old_job' => $notifiable->job,
'new_job' => $notifiable->new_job,
'old_establishment' => $oldEstablishment->name,
'new_establishment' => $newEstablishment->name,
'confirmation_link' => route('confirm-email-change').'?new_email_validation_token='.$notifiable->new_email_validation_token,
Expand Down
3 changes: 1 addition & 2 deletions src/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Ctrlweb\BadgeFactor2\Listeners\RegisterWordPressUser;
use Ctrlweb\BadgeFactor2\Listeners\SendEmailChangeConfirmationRequest;
use Ctrlweb\BadgeFactor2\Listeners\SendTokenToLMS;
use Ctrlweb\BadgeFactor2\Listeners\UpdateEmailInBadgr;
use Ctrlweb\BadgeFactor2\Listeners\UpdateEmailInExternalSystems;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

Expand All @@ -29,7 +28,7 @@ class EventServiceProvider extends ServiceProvider
],
EmailChangeValidated::class => [
UpdateEmailInExternalSystems::class,
]
],
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Badgr/BadgrProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function getFirstResult(string $method, string $endpoint, array $payload
/**
* @param string $method
* @param string $endpoint
* @param array $payload
* @param array $payload
*
* @return mixed
*/
Expand Down

0 comments on commit 1b387c4

Please sign in to comment.