/**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $response = $next($request);
     if ($this->auth->check() && $response instanceof Response) {
         $response->header('Cache-Control', 'no-cache, max-age=0, must-revalidate, no-store');
     }
     return $response;
 }
 /**
  * Responds to requests to GET /
  */
 public function getIndex()
 {
     if (\Auth::check()) {
         return redirect()->to('/birds');
     }
     return view('welcome.index');
 }
Beispiel #3
0
 public function __construct()
 {
     // Asset::add('jquery.dropdown.css', 'css/jquery.dropdown.css');
     Asset::add('bootstrap', 'css/bootstrap.min.css');
     Asset::add('bootstrap-responsive', 'css/bootstrap-responsive.css');
     Asset::add('common', 'css/common.css');
     // Asset::add('style', 'css/style.css');
     Asset::add('fontawsome', 'css/fontawesome.css');
     Asset::add('flickcss', 'css/flick/jquery-ui-1.10.2.custom.css');
     Asset::add('jquery', 'js/jquery-1.9.1.js');
     Asset::add('jquery-migrate-1.1.1.js', 'js/jquery-migrate-1.1.1.js');
     Asset::add('bootstrap-js', 'js/bootstrap.js');
     Asset::add('jqueryui', 'js/jquery-ui-1.10.2.custom.min.js');
     Asset::add('jquery.tablesorter.js', 'js/jquery.tablesorter.js');
     Asset::add('jquery.tablesorter.pager.js', 'js/jquery.tablesorter.pager.js');
     // $files = glob("public/css/pikachoose/*.css", GLOB_BRACE);
     // foreach($files as $file)
     // {
     // 	Asset::add($file, substr($file, 7));
     // }
     if (Session::has('id') && Auth::check()) {
         $account = Account::find(Session::get('id'));
         if ($account->admin == 1) {
             Session::put('admin', '1');
         } else {
             Session::put('admin', '0');
         }
         if ($account->blocked == 1) {
             Session::put('alert', "Your account has been banned. Please contact the admin for more details");
             Session::forget('id');
             Auth::logout();
         } else {
         }
     }
 }
 public function create()
 {
     if (Auth::check()) {
         return Redirect::route('users.show', Auth::user()->username);
     }
     return View::make('sessions.create');
 }
Beispiel #5
0
 public function action_update()
 {
     // If not logged in redirect to home
     if (!\Auth::check()) {
         \Messages::info(__('user.login.not-logged'));
         \Response::redirect_back();
     }
     // was the login form posted?
     if (\Input::method() == 'POST') {
         // check the credentials.
         if (\Auth::instance()->validate_user(\Auth::get_email(), \Input::param('password'))) {
             if (\Input::param('new_password') === \Input::param('confirm_password')) {
                 \Auth::change_password(\Input::param('password'), \Input::param('new_password'));
                 // inform the user the password change was successful
                 \Messages::success(__('user.login.changed'));
                 \Response::redirect_back();
             }
             \Messages::warning(__('user.login.mismatch-password'));
         } else {
             // login failed, show an error message
             \Messages::error(__('user.login.bad-password'));
         }
         \Response::redirect_back('/backend/account/index/password');
     }
     // display the password reset page
     $this->template->content = View::forge('user/password/update');
 }
Beispiel #6
0
 public function getAuthUser()
 {
     if (\Auth::check()) {
         return \Auth::user();
     }
     return null;
 }
 public function before()
 {
     parent::before();
     if (!Auth::check()) {
         Response::redirect('login');
     }
 }
 public function postVote()
 {
     Input::merge(array_map('trim', Input::all()));
     $input = Input::all();
     $rules = array('MCUsername' => 'required|max:40', 'g-recaptcha-response' => 'required|recaptcha', 'sid' => 'required');
     $v = Validator::make($input, $rules);
     $sid = $input['sid'];
     $server = DB::table('mcservers')->where('mcs_id', '=', $sid)->first();
     if (!count($server)) {
         return Redirect::to('/minecraft/' . $sid)->withErrors("Ocorreu um erro com a validação do servidor");
     }
     if ($v->passes()) {
         if (mcservers::playerHasVoted($sid, $input['MCUsername']) || mcservers::ipHasVoted($sid, $_SERVER["HTTP_CF_CONNECTING_IP"])) {
             return Redirect::to('/minecraft/' . $sid)->withErrors("Já votaste hoje");
         }
         if ($server->mcs_votifier == 1) {
             $votifier = Votifier::newVote($server->mcs_ip, $server->mcs_vport, $server->mcs_votifierkey, $input['MCUsername']);
             if ($votifier == false) {
                 return Redirect::to('/minecraft/' . $sid)->withErrors("Não foi possivel enviar o voto para o servidor, porfavor contacta o admininstrador do mesmo");
             }
         }
         if (Auth::check()) {
             DB::table('users')->where('id', Auth::user()->id)->update(array('votes' => Auth::user()->votes + 1));
             utilities::log("Voted On Server " . $server->mcs_name);
         }
         DB::table('mcservers')->where('mcs_id', $sid)->update(array('mcs_tvotes' => $server->mcs_tvotes + 1, 'mcs_mvotes' => $server->mcs_mvotes + 1));
         DB::table('mcserversvotes')->insert(array('mcsv_sid' => $sid, 'mcsv_player' => $input['MCUsername'], 'mcsv_ip' => $_SERVER["HTTP_CF_CONNECTING_IP"], 'mcsv_day' => date("j"), 'mcsv_month' => date("n"), 'mcsv_year' => date("Y")));
         return Redirect::to('/minecraft/' . $sid)->With('success', 'Voto Registado!');
     } else {
         return Redirect::to('/minecraft/' . $sid)->withErrors($v);
     }
 }
Beispiel #9
0
 public function showWelcome()
 {
     if (Auth::check()) {
         return Redirect::action('ProfileController@getProfile', array('username' => Auth::user()->username));
     }
     $this->layout->content = View::make('home.home');
 }
 public function showWelcome()
 {
     if (Auth::check()) {
         return View::make('users.index');
     }
     return View::make('hello');
 }
 public function handle($request, Closure $next)
 {
     if (\Auth::check()) {
         return redirect()->route(\Config::get('admin.home_route'));
     }
     return $next($request);
 }
Beispiel #12
0
 public function before()
 {
     parent::before();
     !Auth::check() and Response::redirect('/auth/login');
     $this->current_user = Model_User::find_by_username(Auth::get_screen_name());
     $this->template->set_global('current_user', $this->current_user);
 }
 public function getSales()
 {
     if (Auth::check()) {
         return View::make('invoice_line');
     }
     return View::make('login');
 }
Beispiel #14
0
/**
 * @return \App\Modules\UserModule\Entities\User|\App\Modules\ShopModule\Entities\Shop|null
 */
function account()
{
    if (!Auth::check()) {
        return null;
    }
    return isRouteInShop() ? shop() : Auth::user();
}
 public function logout()
 {
     if (Auth::check()) {
         Auth::logout();
     }
     return Redirect::route('frontpage');
 }
Beispiel #16
0
 public function create()
 {
     if (Auth::check()) {
         return Redirect::to('/');
     }
     return View::make('sessions.create');
 }
 public function logOut()
 {
     if (Auth::check()) {
         Auth::logout();
         return Redirect::to('login')->with('mensaje_error', 'Sesión Cerrada con Exito');
     }
 }
 public function getLogout()
 {
     if (Auth::check()) {
         Auth::logout();
     }
     return Redirect::to('/');
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::check()) {
         return Redirect::to('dashboard');
     }
     return View::make('page.ingreso');
 }
 public function directorio($directorioCategoria)
 {
     $anuncios = Anuncio::all();
     $categoriasClasif = ClasificadoCategoria::all();
     if ($directorioCategoria == 'all') {
         $listaClasificadosPremium = Clasificado::where('premium', '=', 1)->where('habilitar', '=', 1)->orderBy('fecha_publicacion', 'DESC')->get();
         $listaClasificadosNormales = Clasificado::where('premium', '=', 0)->where('habilitar', '=', 1)->orderBy('fecha_publicacion', 'DESC')->get();
     } else {
         $categoria = ClasificadoCategoria::find($directorioCategoria);
         //$clasificados = $categoria->clasificados;
         $listaClasificadosPremium = Clasificado::where('categoria_id', '=', $directorioCategoria)->where('premium', '=', 1)->where('habilitar', '=', 1)->orderBy('fecha_publicacion', 'DESC')->get();
         $listaClasificadosNormales = Clasificado::where('categoria_id', '=', $directorioCategoria)->where('premium', '=', 0)->where('habilitar', '=', 1)->orderBy('fecha_publicacion', 'DESC')->get();
     }
     $bannersizquierda = Banner::where('seccion', '=', 'CLASIFICADOS-IZQUIERDA')->where('habilitar', '=', 1)->orderBy('id', 'asc')->get();
     $bannersderecha = Banner::where('seccion', '=', 'CLASIFICADOS-DERECHA')->where('habilitar', '=', 1)->orderBy('id', 'asc')->get();
     $bannersindexarriba = Banner::where('seccion', '=', 'INDEX-ARRIBA')->where('habilitar', '=', 1)->orderBy('id', 'asc')->get();
     $rolusuarioLogueado = '';
     $mailusuarioLogueado = '';
     $nombreusuarioLogueado = '';
     if (Auth::check()) {
         $authuser = Auth::user();
         $usu = Usuario::find($authuser->id);
         $mailusuarioLogueado = $authuser->email;
         $nombreusuarioLogueado = $authuser->nombre;
         $rolusuarioLogueado = DB::table('usuario_tiene_rol2')->where('usuario_id', '=', $authuser->id)->first();
         $rolusuarioLogueado = UsuarioRol::find($rolusuarioLogueado->rol_id)->rol;
     }
     return View::make('index.directorioClasificados')->with(array('anuncios' => $anuncios, 'categoriasClasif' => $categoriasClasif, 'listaClasificadosPremium' => $listaClasificadosPremium, 'directorioCat' => $directorioCategoria == 'all' ? 'Todos los clasificados' : $categoria->categoria, 'listaClasificadosNormales' => $listaClasificadosNormales, 'bannersizquierda' => $bannersizquierda, 'bannersderecha' => $bannersderecha, 'bannersindexarriba' => $bannersindexarriba, 'username' => $mailusuarioLogueado, 'nameuser' => $nombreusuarioLogueado, 'roluser' => $rolusuarioLogueado));
     //
 }
Beispiel #21
0
 public static function checkPermission($user, $post)
 {
     if ($post->deleted_at) {
         return false;
     }
     $friend = User::find($post->created_by);
     if (Auth::check()) {
         if ($post->created_by != $user->id) {
             switch ($post->privacy_level) {
                 case Post::_PRIVATE:
                     return false;
                     break;
                 case Post::_FRIEND:
                     $can_see = $user->friendship($friend);
                     if ($can_see == Friend::STRANGER) {
                         return false;
                     }
                     break;
                 case Post::_CUSTOM:
                     $can_see = DB::table('friend_post')->where('post_id', $post->id)->where('friend_id', Auth::user()->id)->first();
                     if (is_null($can_see)) {
                         return false;
                     }
                     break;
                 case Post::_PUBLIC:
                 default:
                     break;
             }
         }
     } else {
         return $post->privacy_level == Post::_PUBLIC;
     }
     return true;
 }
Beispiel #22
0
 public function authorize()
 {
     // Only allow logged in users
     return \Auth::check();
     // Allows all users in
     //return true;
 }
Beispiel #23
0
 public function login()
 {
     if (\Auth::check()) {
         return \Redirect::intended(\URL::route('me.index'));
     }
     $this->layout->content = \View::make('auth.login');
 }
Beispiel #24
0
 public function showIndex()
 {
     if (!Auth::check()) {
         return View::make('login', array('title' => 'edison'));
     }
     $category_names = array('ent' => 'エンターテイメント', 'music' => '音楽', 'sing' => '歌ってみた', 'play' => '演奏してみた', 'dance' => '踊ってみた', 'vocaloid' => 'VOCALOID', 'nicoindies' => 'ニコニコインディーズ', 'animal' => '動物', 'cooking' => '料理', 'nature' => '自然', 'travel' => '旅行', 'sport' => 'スポーツ', 'lecture' => 'ニコニコ動画講座', 'drive' => '車載動画', 'history' => '歴史', 'politics' => '政治', 'science' => '科学', 'tech' => 'ニコニコ技術部', 'handcraft' => 'ニコニコ手芸部', 'make' => '作ってみた', 'anime' => 'アニメ', 'game' => 'ゲーム', 'toho' => '東方', 'imas' => 'アイドルマスター', 'radio' => 'ラジオ', 'draw' => '描いてみた', 'are' => '例のアレ', 'diary' => '日記', 'other' => 'その他', 'r18' => 'R-18', 'original' => 'オリジナル', 'portrait' => '似顔絵', 'character' => 'キャラクター');
     $all_items = Item::orderBy('created_at', 'desc')->take(10)->get();
     foreach ($all_items as &$item) {
         $item['user'] = User::where('id', '=', $item->user_id)->get()[0];
         $item['star_count'] = Starmap::where('item_id', '=', $item->id)->count();
         $item['comment_count'] = Comment::where('item_id', '=', $item->id)->count();
         if ($item->category_id != 0) {
             $item['category'] = Category::where('id', '=', $item->category_id)->get()[0]->content;
         }
     }
     $recent_works = Work::orderBy('created_at', 'desc')->take(10)->get();
     foreach ($recent_works as &$work) {
         $item = Item::where('id', '=', $work->item_id)->get()[0];
         $work['item'] = $item;
         $work['user'] = User::where('id', '=', $work->user_id)->get()[0];
         $work['item_poster_screen_name'] = User::where('id', '=', $item->user_id)->get()[0]->screen_name;
         if ($item->category_id != 0) {
             $work['item_category'] = Category::where('id', '=', $item->category_id)->get()[0]->content;
         }
     }
     $user = User::where('screen_name', '=', Auth::user()->screen_name)->get()[0];
     $data = array('title' => 'edison', 'user' => $user, 'all_items' => $all_items, 'recent_works' => $recent_works, 'categories' => $category_names, 'star_count' => Starmap::where('user_id', '=', $user->id)->count(), 'work_count' => Work::where('user_id', '=', Auth::user()->id)->count());
     return View::make('index', $data);
 }
Beispiel #25
0
 public function action_login()
 {
     // Already logged in
     Auth::check() and Response::redirect('admin');
     $val = Validation::forge();
     if (Input::method() == 'POST') {
         $val->add('email', 'Email or Username')->add_rule('required');
         $val->add('password', 'Password')->add_rule('required');
         if ($val->run()) {
             if (!Auth::check()) {
                 if (Auth::login(Input::post('email'), Input::post('password'))) {
                     // assign the user id that lasted updated this record
                     foreach (\Auth::verified() as $driver) {
                         if (($id = $driver->get_user_id()) !== false) {
                             // credentials ok, go right in
                             $current_user = Model\Auth_User::find($id[1]);
                             Session::set_flash('success', e('Welcome, ' . $current_user->username));
                             Response::redirect_back('admin');
                         }
                     }
                 } else {
                     $this->template->set_global('login_error', 'Login failed!');
                 }
             } else {
                 $this->template->set_global('login_error', 'Already logged in!');
             }
         }
     }
     $this->template->title = 'ITNT Timesheets Login';
     $this->template->content = View::forge('admin/login', array('val' => $val), false);
 }
Beispiel #26
0
 public function get()
 {
     $user_id = false;
     if (Auth::check()) {
         // Authenticating A User And "Remembering" Them
         Session::regenerate();
         $user_id = Auth::user()->id;
         if (Auth::user()->accountType == 1) {
             if (Session::has('admin_session')) {
                 Log::info("admin_session already created before - " . Session::get('admin_session'));
             } else {
                 Session::put('admin_session', $user_id);
                 Log::info("admin_session created");
             }
         }
         //            Log::info("Session cre8 - " . Session::get('admin_session'));
     }
     //        else if (Auth::viaRemember()) {
     //            // Determining If User Authed Via Remember
     //            $user_id = Auth::user()->id;
     //        }
     if (!$user_id) {
         $error_response = array('error' => array('message' => 'User not logged in.', 'type' => 'OAuthException', 'code' => 400));
         Log::info("User not logged in");
         return Response::json($error_response, 400)->setCallback(Input::get('callback'));
     }
     $user = User::find(Auth::user()->id);
     return Response::json($user)->setCallback(Input::get('callback'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::check()) {
         return Redirect::to('admin/panelAdmin');
     }
     return View::make('admin/login');
 }
 public function fbConnect()
 {
     if (!Auth::check()) {
         $fb_user = Input::get('fb_user');
         $user = User::where('email', '=', $fb_user['email'])->first();
         if ($user != null) {
             if ($user->count()) {
                 Auth::login($user);
                 $user->last_login_at = new DateTime('now');
                 $user->last_ip_address = $_SERVER["REMOTE_ADDR"];
                 $user->save();
                 return Response::json(array('status' => 'logging'));
             } else {
                 //create user account
                 $user = User::create(array('email' => '*****@*****.**', 'username' => 'Monkey', 'password' => Hash::make($this->gen_random_string(12)), 'code' => str_random(60), 'active' => 1));
                 //normally active = 0 but until we can get email validation working it will stay 1);
                 $user->save();
                 Auth::login($user);
                 return Response::json(array('status' => 'registering'));
             }
         } else {
             $fb_user_name = explode(" ", $fb_user['name']);
             //create user account
             $user = User::create(array('email' => $fb_user['email'], 'username' => $fb_user['name'], 'password' => Hash::make($this->gen_random_string(12)), 'first_name' => $fb_user_name[0], 'last_name' => $fb_user_name[1], 'code' => str_random(60), 'active' => 1));
             //normally active = 0 but until we can get email validation working it will stay 1);
             $user->save();
             Auth::login($user);
             return Response::json(array('status' => 'registering'));
         }
     } else {
         return Response::json(array('status' => 'logged'));
     }
 }
Beispiel #29
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     if (\Auth::check()) {
         return true;
     }
     return true;
 }
Beispiel #30
0
 public function userBanned()
 {
     if (Auth::check() && !Auth::user()->is_banned) {
         return Redirect::route('home');
     }
     return View::make('auth.userbanned');
 }