public function getLogin()
 {
     if (!Auth::guest()) {
         return Redirect::action('HomeController@getIndex');
     }
     try {
         # Change 'localhost' to your domain name.
         $openid = new LightOpenID($_SERVER['HTTP_HOST']);
         if (!$openid->mode) {
             $openid->identity = 'http://steamcommunity.com/openid';
             return Redirect::to($openid->authUrl());
         } elseif ($openid->mode == 'cancel') {
             echo 'User has canceled authentication!';
         } else {
             if ($openid->validate()) {
                 $id = $openid->identity;
                 // identity is something like: http://steamcommunity.com/openid/id/76561197994761333
                 // we only care about the unique account ID at the end of the URL.
                 $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/";
                 preg_match($ptn, $id, $matches);
                 $steamid = $matches[1];
                 $this->fetch_username($steamid);
                 $this->fetch_backpack($steamid);
                 Auth::loginUsingId($steamid, true);
                 return Redirect::action('HomeController@getIndex');
             } else {
                 echo "User is not logged in.\n";
             }
         }
     } catch (ErrorException $e) {
         echo $e->getMessage();
     }
 }
 public function getIndex()
 {
     if (Auth::guest() || Auth::user()->isAdmin == 0) {
         return Redirect::secure('/');
     }
     // layouts variables
     $this->layout->title = 'Админ панел | Нещо Шантаво';
     $this->layout->canonical = 'https://neshto.shantavo.com/admin/';
     $this->layout->robots = 'noindex,nofollow,noodp,noydir';
     $users = count(User::all());
     $admins = count(User::where('isAdmin', ">", 0)->get());
     $categories = count(Category::all());
     $albums = count(Album::all());
     $votes = count(DB::table('votes')->get());
     $pictures = count(Picture::all());
     $pictureSize = 0;
     foreach (Picture::all() as $p) {
         $pictureSize += $p->size;
     }
     // get disqus stats
     include app_path() . '/config/_disqus.php';
     $disqus = new DisqusAPI(getDisqusKey());
     $disqus->setSecure(false);
     $comments = $disqus->posts->list(array('forum' => 'shantavo'));
     // nesting the view into the layout
     $this->layout->nest('content', 'admin.index', array('users' => $users, 'admins' => $admins, 'votes' => $votes, 'categories' => $categories, 'albums' => $albums, 'pictures' => $pictures, 'pictureSize' => $pictureSize, 'comments' => $comments));
 }
Example #3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->is('login') && \Auth::guest()) {
         return redirect()->action('LoginController@form');
     }
     return $next($request);
 }
Example #4
0
 function get_index()
 {
     if (Auth::guest()) {
         return View::make('login');
     }
     return Redirect::to('admin');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->guest()) {
         if ($request->ajax()) {
             dd('Unauthorized');
             return response('Unauthorized.', 401);
         } else {
             session_start();
             if (isset($_SESSION['cart'])) {
                 if (\Request::all()) {
                     array_push($_SESSION['cart'], \Request::all());
                 }
             } else {
                 $_SESSION['cart'] = [];
                 array_push($_SESSION['cart'], \Request::all());
             }
             if (\Auth::guest()) {
                 \Session::flash('need_to_login_message', 'You need to log in');
             }
             // dd($_SESSION['cart']);
             return redirect()->guest('login');
         }
     }
     return $next($request);
 }
Example #6
0
 /**
  * Display the Login Page.
  *
  * @return Response
  */
 public function getLogin()
 {
     if (Auth::guest()) {
         return View::make('auth.login');
     }
     return Redirect::to('dashboard');
 }
 public function create()
 {
     $dc_name = Input::get('dc-name');
     $dc_desc = Input::get('dc-desc');
     $dc_donation_url = Input::get('dc-donation-url');
     $dc_instructions = Input::get('dc-instructions');
     if (Auth::guest()) {
         /////// Create User of type donationcause_adder
         $dcadder_first_name = Input::get('dcadder-first-name');
         $dcadder_last_name = Input::get('dcadder-last-name');
         $dcadder_mobile = Input::get('dcadder-mobile');
         $dcadder_obj = User::createDCAdderAndSave($dcadder_first_name, $dcadder_last_name, $dcadder_mobile);
         // =====[start]================================================
         // Manually logging in user and 'Remember me' = true.
         // So no need to use Auth::attempt
         Auth::login($dcadder_obj, true);
         // =====[end]================================================
     }
     if (Auth::guest()) {
         dd('why is there no Authenticated User here');
     }
     if (!Auth::user()->donationcause_adder) {
         Auth::user()->makeDonationCauseAdder();
     }
     // Storing the image
     $dc_img_file = Input::file('dc-img-file');
     DonationCause::createNewForPosterFromImgFile($dc_name, $dc_desc, $dc_img_file, $dc_donation_url, $dc_instructions, Auth::user()->id);
     return Redirect::route('donate');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->is('auth/login') && \Auth::guest()) {
         return redirect('/auth/login');
     }
     return $next($request);
 }
Example #9
0
 public function index()
 {
     if (!Auth::guest()) {
         return $this->redirectStatus();
     }
     return View::make('session.login');
 }
 public function addContributor()
 {
     $contributor_first_name = Input::get('contributor-first-name');
     $contributor_last_name = Input::get('contributor-last-name');
     $contributor_mobile = Input::get('contributor-mobile');
     $contributor_obj = NULL;
     if (Auth::guest()) {
         $contributor_obj = User::createContributorAndSave($contributor_first_name, $contributor_last_name, $contributor_mobile);
         Auth::login($contributor_obj, true);
     } else {
         // A user is logged in already. The contributor name and mobile can be same or different
         // ONLY checking by mobile right now. TODO : check if this is OK
         if ($contributor_mobile != Auth::user()->mobile) {
             Log::info("mobile num not equal. MAKE NEW CONTRIB USER !!");
             // Using same contributor twice. Or uses existing user as contributor without knowing that they exist on this platform
             $contributor_obj = User::createContributorIfNotExists($contributor_first_name, $contributor_last_name, $contributor_mobile);
         } else {
             Log::info("mobile num equal. Auth is Contributor !! ");
             $contributor_obj = Auth::user();
             $contributor_obj->makeContributor();
         }
     }
     $au_file = Input::file('au-file');
     $upload_number = Auth::user()->incrementUploadNumber();
     $new_file_name = $contributor_first_name . $contributor_mobile . '_uploaded_by_' . Auth::user()->fname . $upload_number . '.csv';
     $new_file_location = app_path() . '/database/seedAfterReview/';
     $au_file->move($new_file_location, $new_file_name);
     // I will review. No automatic upload
     //$file_full_path = $new_file_location . $new_file_name;
     //Helper::createArmyUpdatesFromFileForContributor($file_full_path, $contributor_obj->id);
     return Redirect::to('dashboard');
 }
 private function _isUnread()
 {
     if (Auth::guest()) {
         return false;
     }
     $markAsReadAfter = value(Config::get('forums::forums.mark_as_read_after'));
     if (!IoC::registered('topicsview')) {
         IoC::singleton('topicsview', function () use($markAsReadAfter) {
             return Forumview::where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter))->where('user_id', '=', Auth::user()->id)->lists('topic_id');
         });
     }
     $tv = IoC::resolve('topicsview');
     $nb = count($tv);
     $view = Forumtopic::where('forumcategory_id', '=', $this->id)->where('updated_at', '>=', date('Y-m-d H:i:s', $markAsReadAfter));
     if ($nb > 0) {
         $view = $view->where_not_in('id', $tv);
     }
     $view = $view->count();
     if ($nb == 0 && $view > 0) {
         return true;
     }
     if ($view > 0) {
         return true;
     }
     return false;
 }
Example #12
0
 /**
  * Boot the creation trait for a model.
  *
  * @return void
  */
 public static function bootCreation()
 {
     // create a event to happen on deleting
     static::deleting(function ($table) {
         if (class_exists('Cartalyst\\Sentinel\\Laravel\\Facades\\Sentinel')) {
             $table->deleted_by = Sentinel::getUser()->id;
         } else {
             $table->deleted_by = Auth::user()->id;
         }
         $table->update(['deleted_by' => $table->deleted_by]);
     });
     // create a event to happen on saving
     static::saving(function ($table) {
         if (class_exists('Cartalyst\\Sentinel\\Laravel\\Facades\\Sentinel')) {
             if (Sentinel::check()) {
                 $table->modified_by = Sentinel::getUser()->id;
             }
             if (Sentinel::check() && ($table->created_by == null || !($table->created_by > 0))) {
                 $table->created_by = Sentinel::getUser()->id;
             }
         } else {
             if (!Auth::guest()) {
                 $table->modified_by = Auth::user()->id;
             }
             if (!Auth::guest() && ($table->created_by == null || !($table->created_by > 0))) {
                 $table->created_by = Auth::user()->id;
             }
         }
     });
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (\Auth::guest()) {
         return redirect('auth/login');
     }
     return view('admin/register');
 }
Example #14
0
 public function handleNotFound()
 {
     if (\Auth::guest()) {
         return redirect('/auth/login');
     }
     return response(view('index')->render());
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\Auth::guest()) {
         return redirect('/login');
     }
     return $next($request);
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /sessions/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy()
 {
     if (!Auth::guest()) {
         Auth::logout();
     }
     return Redirect::to('/');
 }
Example #17
0
 public function isCurrent()
 {
     if (Auth::guest()) {
         return false;
     }
     return Auth::user()->id == $this->id;
 }
Example #18
0
    public function action_facebookConnect()
    {
        assert(Auth::guest());
        $profile = Helper::facebook()->api('/me');
        $user = Model\User::where_facebook_id($profile['id'])->first();
        if (!$user) {
            $user = new Model\User();
            $user->facebook_id = $profile['id'];
            $user->name = $profile['name'];
            $user->save();
        }
        Auth::login($user->id);
        ?>
		<html>
			<head>
				<script type="text/javascript">
					if (window.opener) {
						window.opener.location = '<?php 
        echo URL::to_route('login');
        ?>
';
						window.close();
					} else {
						window.location = '<?php 
        echo URL::to_route('login');
        ?>
';
					}
				</script>
			</head>	
			<body>
			</body>
		</html>
		<?php 
    }
Example #19
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     if (\Auth::guest()) {
         return false;
     }
     return parent::authorize();
 }
 public function incrementViews($table, $row, $rowValue, $columnToIncrement = 'views')
 {
     //only increment if not admin user
     if (Auth::guest() || !Auth::user()->group_id > 1) {
         DB::table($table)->where($row, '=', $rowValue)->increment($columnToIncrement);
     }
 }
Example #21
0
 public static function InitConnect()
 {
     if (!Auth::guest()) {
         return json_encode(['Type' => 'Hello', 'id' => Auth::user()->id, 'name' => Auth::user()->username]);
     } else {
         return json_encode(['Type' => 'Hello', 'id' => '0', 'name' => 'Guest' . rand()]);
     }
 }
Example #22
0
 public function action_index()
 {
     if (Auth::guest()) {
         return View::make('login.index');
     } else {
         return Redirect::to('home');
     }
 }
Example #23
0
function credentialsMatch($username)
{
    $user = User::byUsername($username);
    if (Auth::guest() || Auth::user()->id !== $user->id) {
        return false;
    }
    return true;
}
 /**
  * Checking user authentication.
  *
  * @param  int $id
  * @return int | bool
  */
 private function checkAuth($id)
 {
     if (!Auth::guest()) {
         return Votes::where('image_id', $id)->where('user_id', Auth::user()->id)->count();
     } else {
         return false;
     }
 }
Example #25
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $post = Post::find($id);
     if ($post && !(Auth::guest() && $post->hasTag(Lang::get('tags.closed')))) {
         return View::make('post.show', compact('post'));
     }
     App::abort(404);
 }
Example #26
0
 public function checkLoggedIn()
 {
     $temp = \Config::get('auth.model');
     \Config::set('auth.model', 'Serverfireteam\\Panel\\Admin');
     $access = !\Auth::guest();
     \Config::set('auth.model', $temp);
     return $access;
 }
 public function action_index()
 {
     if (Auth::guest()) {
         return Event::first('404');
     }
     $topics = Forumtopic::getPosted();
     return View::make('forums::posted.index', array('topics' => $topics));
 }
Example #28
0
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (\Auth::guest()) {
         return view('login');
     } else {
         return view('twitter_page');
     }
 }
Example #29
0
 /**
  * Checks to see if the user is logged in. If they aren't we get redirected to the login page
  * @return header redirect
  */
 public function auth()
 {
     if (Auth::guest()) {
         return Redirect::to('admin/login');
     }
     //        if (Auth::guest()) return Redirect::to('home');
     //        if (Auth::guest()) return Redirect::to('/');
 }
Example #30
0
 /**
  * @return mixed
  */
 public function getIndex()
 {
     if (!Auth::guest() && Auth::user()->rule == 2) {
         return $this->getDashboard();
     } else {
         return View::make('admin.login');
     }
 }