Exemplo n.º 1
0
 /**
  * Handle the event.
  *
  * @param  Events $event
  * @return void
  */
 public function handle(User $user, $remember)
 {
     $token = new Token();
     $token->generate();
     Session::put('token', $token->token);
     // We will grant the user all roles to which he is entitled!
     $rootcommittee = Committee::where('slug', config('proto.rootcommittee'))->first();
     $boardcommittee = Committee::where('slug', config('proto.boardcommittee'))->first();
     $omnomcom = Committee::where('slug', config('proto.omnomcom'))->first();
     $pilscie = Committee::where('slug', config('proto.pilscie'))->first();
     if ($user->isInCommittee($rootcommittee)) {
         if (!$user->hasRole('admin')) {
             $user->attachRole(Role::where('name', '=', 'admin')->first());
         }
     } else {
         if ($user->hasRole('admin')) {
             $user->detachRole(Role::where('name', '=', 'admin')->first());
         }
     }
     if ($user->isInCommittee($boardcommittee)) {
         if (!$user->hasRole('board')) {
             $user->attachRole(Role::where('name', '=', 'board')->first());
         }
     } else {
         if ($user->hasRole('board')) {
             $user->detachRole(Role::where('name', '=', 'board')->first());
         }
     }
     if ($user->isInCommittee($omnomcom)) {
         if (!$user->hasRole('omnomcom')) {
             $user->attachRole(Role::where('name', '=', 'omnomcom')->first());
         }
     } else {
         if ($user->hasRole('omnomcom')) {
             $user->detachRole(Role::where('name', '=', 'omnomcom')->first());
         }
     }
     if ($user->isInCommittee($pilscie)) {
         if (!$user->hasRole('pilscie')) {
             $user->attachRole(Role::where('name', '=', 'pilscie')->first());
         }
     } else {
         if ($user->hasRole('pilscie')) {
             $user->detachRole(Role::where('name', '=', 'pilscie')->first());
         }
     }
 }
Exemplo n.º 2
0
 public function protubePlayed(Request $request)
 {
     if ($request->secret != env('HERBERT_SECRET')) {
         abort(403);
     }
     $playedVideo = new PlayedVideo();
     $token = Token::where('token', $request->token)->first();
     if ($token) {
         $user = $token->user()->first();
         $playedVideo->user()->associate($user);
     }
     $playedVideo->video_id = $request->video_id;
     $playedVideo->video_title = $request->video_title;
     $playedVideo->save();
 }