Fix appointment policy not being called correctly

This commit fixes the appointment policy being called at the wrong time, with the wrong arguments.
It also fixes wrong references on the auth service provider, also fixing other issues with poliy usage.

Fixes #3 and SPACEJEWEL-HOSTING-59.
This commit is contained in:
Miguel Nogueira 2020-07-16 05:24:00 +01:00
parent bca6020ab0
commit 4a766620ff
2 changed files with 12 additions and 8 deletions

View File

@ -67,7 +67,6 @@ class AppointmentController extends Controller
public function updateAppointment(Request $request, $applicationID, $status)
{
$this->authorize('update', Appointment::class);
$application = Application::find($applicationID);
$validStatuses = [
@ -75,6 +74,9 @@ class AppointmentController extends Controller
'CONCLUDED'
];
$this->authorize('update', $application->appointment);
if (!is_null($application))
{

View File

@ -2,15 +2,15 @@
namespace App\Providers;
use App\Http\Controllers\BanController;
use App\Http\Controllers\VoteController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\AppointmentController;
use App\Policies\ProfilePolicy;
use App\Policies\VacancyPolicy;
use App\Policies\UserPolicy;
use App\Policies\BanPolicy;
use App\Policies\FormPolicy;
use App\Policies\VotePolicy;
use App\Policies\ApplicationPolicy;
use App\Policies\AppointmentPolicy;
use App\User;
use App\Form;
use App\Vote;
@ -18,6 +18,8 @@ use App\Vacancy;
use App\Application;
use App\Appointment;
use App\Ban;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
@ -36,9 +38,9 @@ class AuthServiceProvider extends ServiceProvider
Vacancy::class => VacancyPolicy::class,
//Form::class => FormPolicy::class
'App\Form' => 'App\Policies\FormPolicy',
Vote::class => VoteController::class,
Ban::class => BanController::class,
Appointment::class => AppointmentController::class
Vote::class => VotePolicy::class,
Ban::class => BanPolicy::class,
Appointment::class => AppointmentPolicy::class
];
/**