예제 #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect('/home')->with('auth_message', 'Must be logged in.');
         }
     }
     /** @var \JamylBot\User $user */
     $user = $this->auth->user();
     if ($user->admin) {
         return $next($request);
     }
     $groupId = $request->groupId ? $request->groupId : $request->groups;
     if ($groupId) {
         /** @var Group $group */
         $group = Group::find($groupId);
         if ($group->isOwner($user->id)) {
             return $next($request);
         }
     }
     if ($request->ajax()) {
         return response('Unauthorized.', 401);
     } else {
         return redirect('/home')->with('auth_message', 'Access Denied');
     }
 }
예제 #2
0
 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $groups = [];
     /** @var Group $group */
     foreach (Group::all() as $group) {
         if ($group->isOwner($this->user->id)) {
             $groups[] = $group;
         }
     }
     return view('home', ['name' => $this->user->char_name, 'avatar' => $this->user->getAvatarUrl(), 'email' => $this->user->email, 'slackName' => $this->user->slack_name, 'status' => $this->user->status, 'corp' => $this->user->corp_name, 'alliance' => $this->user->alliance_name, 'charId' => $this->user->char_id, 'groups' => $groups]);
 }
예제 #3
0
 public function removeOwnerFromGroup($groupId)
 {
     /** @var Group $group */
     $group = Group::find($groupId);
     $group->removeOwner(\Request::input('owner'));
     return redirect('/admin/groups/' . $groupId);
 }