Skip to content

Commit

Permalink
Fix missing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kipjr committed Sep 8, 2024
1 parent 6b805c4 commit ff65f46
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions app/Http/Controllers/MensaAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Mail\SigninCancelled;
use App\Models\Mensa;
use App\Models\MensaUser;
use App\Helpers\MSGraphAPI\Application as AzureAppInfo;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
Expand Down Expand Up @@ -118,7 +119,8 @@ public function newSignin(Request $request, $mensaId){

public function requestUserLookup(Request $request){
$request->validate(['name' => 'regex:/^[a-zA-Z _]+$/']);
return response()->json($this->searchAzureUsers($request->get('name')));
$azureAppInfo = new AzureAppInfo();
return response()->json($azureAppInfo->searchAzureUsers($request->get('name')));
}

public function printState(Request $request, $mensaId){
Expand Down Expand Up @@ -205,8 +207,8 @@ public function bulkSignin(Request $request, $mensaId, $lidnummer){
} catch(ModelNotFoundException $e){
return redirect(route('home'))->with('error', 'Mensa niet gevonden!');
}

$user = $this->getAzureUserBy('description', $lidnummer);
$azureAppInfo = new azureAppInfo;
$user = $azureAppInfo->getAzureUserBy('description', $lidnummer);
if($user == null){
return redirect()->back()->with('error', 'Inschrijving niet gevonden! Als je denkt dat dit een fout is neem dan contact op met ' . config('mensa.contact.mail') . '.');
}
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/SigninController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public function newSignin(Request $request, $mensaId, $lidnummer = null){
// If the user is a mensa admin, we allow him to sign someone else in with his lidnummer
if($lidnummer != null && Auth::check() && Auth::user()->mensa_admin){
try {
$user = $this->getAzureUserBy('description', $lidnummer);
$azureAppInfo = new azureAppInfo;
$user = $AzureAppInfo->getAzureUserBy('description', $lidnummer);
$request->session()->flash('extra_lidnummer', $lidnummer);
} catch(ModelNotFoundException $e){
return redirect(route('home'))->with('error', 'Persoon niet gevonden!');
Expand Down Expand Up @@ -95,7 +96,8 @@ public function newSignin(Request $request, $mensaId, $lidnummer = null){
// If we already got POST data, we want to process some stuff
// If we didn't provide a lidnummer but an email is provided, we want to check Azure
if($lidnummer == null && $request->has('email')){
$user = $this->getAzureUserBy('email', $request->input('email'));
$azureAppInfo = new azureAppInfo;
$user = $azureAppInfo->getAzureUserBy('email', $request->input('email'));
// We check if the user can be found in Azure, and if not, we return back to the form with an error message
if($user == null){
$mensaUser->user()->associate(new User());
Expand Down

0 comments on commit ff65f46

Please sign in to comment.