Esempio n. 1
0
 /**
  * Allow a request to proceed only if we hold a valid OAuth token
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\App\Http\Helpers\OAuth::valid()) {
         return $next($request);
     } else {
         return \App\Http\Helpers\OAuth::toAuthorisationServer($request->route()->getUri());
     }
 }
Esempio n. 2
0
 /**
  * Overwrite the handicap of a user
  */
 public function setHandicap()
 {
     $user = OAuth::user();
     $user->handicap = Request::get('handicap');
     if ($user->save()) {
         return response()->json(null, 200);
     } else {
         return response()->json(['error' => 'handicap_update_failed', 'error_details' => 'Je dieetwensen konden niet worden opgeslagen'], 500);
     }
 }
Esempio n. 3
0
 /**
  * Allow a request to proceed only if we have board-level permissions
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!App\Http\Helpers\OAuth::valid()) {
         App::abort(500, 'Attempted board authorization without a valid session');
     }
     if (App\Http\Helpers\OAuth::isBoardMember()) {
         // Proceed with request
         return $next($request);
     } else {
         App::abort(403, 'Access denied: you\'re not authorized to access this');
     }
 }
Esempio n. 4
0
 /**
  * Format the main navigation into proper HTML
  * @return string rendered HTML
  */
 public static function show()
 {
     $output = '';
     // Determine which elements to show
     $level = 0;
     if (OAuth::valid()) {
         $level = 1;
         if (OAuth::isBoardMember()) {
             $level = 2;
         }
     }
     foreach (self::$menu as $entry) {
         if ($level >= $entry['level']) {
             $entry['current'] = self::isCurrent($entry['url']);
             $output .= view('navigation/item')->with($entry);
         }
     }
     return $output;
 }
Esempio n. 5
0
 /**
  * Wrap the content provided in the default template
  * @param View $view the View file to provide
  */
 protected function setPageContent(\Illuminate\View\View $view)
 {
     return view($this->layout, ['content' => $view, 'javascript' => $this->loadControllerJavascript(), 'user' => OAuth::user()]);
 }
Esempio n. 6
0
 /**
  * Unsubscribe a user from a meal
  * @return JSON
  */
 public function afmelden()
 {
     // Find the meal
     $meal = Meal::find((int) Request::input('meal_id'));
     if (!$meal) {
         return response()->json(['error' => 'meal_not_found', 'error_details' => 'De maaltijd bestaat niet'], 404);
     }
     // Check if the meal is still open
     if (!$meal->open_for_registrations()) {
         return response()->json(['error' => 'meal_deadline_expired', 'error_details' => 'De aanmeldingsdeadline is verstreken'], 400);
     }
     // Find the registration data
     $user = OAuth::user();
     $registration = $user->registrationFor($meal);
     if (!$registration) {
         return response()->json(['error' => 'no_registration', 'error_details' => 'Je bent niet aangemeld voor deze maaltijd'], 404);
     }
     // Destroy the registration
     $id = $registration->id;
     $name = $registration->name;
     $registration->delete();
     \Log::info("Afgemeld {$registration->name} (ID: {$registration->id}) voor {$meal} (ID: {$meal->id}) door {$user->name} (ID: {$user->id})");
     return response(null, 200);
 }
<?php

$meal = App\Models\Meal::today()->first();
$user = \App\Http\Helpers\OAuth::user();
if (!$meal || !$user) {
    return;
}
if ($meal && !$meal->open_for_registrations() && $user->registeredFor($meal)) {
    ?>
    <div class="notification success">
        <img src="/images/tick.png" alt="">
        Ja, je bent aangemeld voor vandaag.
    </div>
<?php 
}
Esempio n. 8
0
 public static function photoURL()
 {
     // Must have a valid session
     if (!OAuth::valid()) {
         return null;
     }
     $user = self::user();
     $access_token = Session::get('oauth.token')->access_token;
     return 'https://people.debolk.nl/persons/' . $user->username . '/photo/128/128?access_token=' . $access_token;
 }
Esempio n. 9
0
 /**
  * Redirects to a photo of the user
  * @return Redirect
  */
 public function photo()
 {
     return redirect(OAuthHelper::photoURL());
 }