public function start() { if (Auth::check()) { return \View::make('dashboard')->with('name', 'ritesh'); } return Redirect::to('auth/login'); }
public function edit(Donations $donations) { if (!Auth::check()) { return redirect('donations'); } return view('edit', compact('donations')); }
/** * @test */ public function it_logs_a_user_out() { $this->preparePageContent(); $user = factory('App\\User')->create(); $this->actingAs($user)->visit('admin/logout'); $this->assertFalse(Auth::check(), 'user not logged out'); }
public function addTask(Request $req, $name_liste) { $param = $req::all(); if ($param['task'] != "" && strtotime($param['date']) != 0) { $tache = new \App\Tache(); $tache->name_user = Auth::user()->email; $tache->name_liste = $name_liste; $tache->etat_tache = "No"; $tache->tache = $param['task']; $tache->date = $param['date']; $tache->save(); // Update nombre de tâche de Liste $log = Auth::user()->email; $liste = new \App\Liste(); $liste = Liste::where('name_liste', $name_liste)->where('name_user', $log)->first(); $liste->tache_tot = $liste->tache_tot + 1; $liste->save(); return redirect()->route('index'); } else { // //$this->fail = 'erreur'; //echo $this->fail ; if (Auth::check()) { $log = Auth::user()->email; $todo = DB::table('listes')->where('name_user', $log)->get(); } else { $todo = null; } $this->erreur = "yes"; return view('index', ['todo' => $todo, 'erreur' => $this->erreur]); } }
public function handle($request, Closure $next) { if (!Auth::check()) { return redirect('/login'); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next, $guard = null) { if (!Auth::check() || !Auth::guard($guard)->user()->admin) { return redirect('/'); } return $next($request); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { if (Auth::check()) { return redirect('/home'); } return view('auth.login'); }
public function handle($request, Closure $next) { if (Auth::check() && Auth::user()->isAdmin()) { return $next($request); } return redirect('/'); }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { if (Auth::check()) { return true; } return false; }
public function earnedAchievements() { if (empty($this->earned)) { if (Auth::check()) { $from_lesson = $this->course->achievements()->where('lesson_id', $this->id)->get(); $from_num_lessons = []; $fnl = $this->course->achievements()->whereNotNull('num_lessons')->get(); foreach ($fnl as $a) { if (Auth::user()->lessons()->where('course_id', $this->course->id)->count() >= $a->num_lessons) { $from_num_lessons[] = $a; } } $achievements = array_merge($from_lesson->all(), $from_num_lessons); //$own_achievements = Auth::user()->achievements; $earned = []; foreach ($achievements as $a) { if (Auth::user()->achievements()->where('achievement_id', $a->id)->count() == 0) { $earned[] = $a; } } foreach ($earned as $a) { Auth::user()->achievements()->attach($a->id); } $this->earned = $earned; return collect($earned); } else { return collect([]); } } else { return collect($this->earned); } }
/** * Create a new post * @param string $body Content of post, will be run through filters * @param integer $threadid Thread ID * @param integer| $posterid Poster's ID. Defaults to currently authenticated user * @param bool|false $hidden Is the post hidden from normal view? * @param bool|true $save Should the post be automatically saved into the database? * @return Post The resulting post object */ public static function newPost($body, $threadid, $posterid = null, $hidden = false, $save = true) { // Check users rights if (!Auth::check() && $posterid === null) { abort(403); // 403 Forbidden } // Check thread $thread = Thread::findOrFail($threadid); if ($thread->locked) { abort(403); // 403 Forbidden } // Run post through filters $body = PostProcessor::preProcess($body); // Create new post $post = new Post(); $post->thread_id = $threadid; $post->poster_id = Auth::user()->id; $post->body = $body; $post->hidden = $hidden; // defaults to false // Put post into database if ($save) { $post->save(); } return $post; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * @return mixed */ public function handle($request, Closure $next) { if (Auth::check() && Auth::user()->username == Auth::user()->facebook_id && strpos($request->route()->getName(), 'user') === false) { return redirect()->route('user/editSelf')->with('message', 'You must finish editing your account.'); } return $next($request); }
public function getLoginAction() { if (Auth::check()) { return redirect('/admin'); } return view('admin.login'); }
public function login() { if (Auth::check() && Auth::user()->isAdmin()) { return redirect('admin/dashboard'); } return view('auth/admin-login', ['body_class' => 'login']); }
/** * Show the application dashboard. * * @return Response */ public function index() { if (Auth::check() && Auth::user()->admin) { return redirect()->route('admin'); } return redirect()->route('etudiant'); }
/** * @return mixed */ public function filter() { if (!Auth::check() or !Auth::user()->is('admin')) { Auth::logout(); return Redirect::route('admin.login.index'); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function __construct() { $this->middleware('auth'); if (Auth::check()) { $this->middleware('admin'); } }
public function __construct() { $this->loggedInUser = Auth::User(); $this->loggedInViaRememberMe = Auth::viaRemember(); view()->share('isSignedIn', Auth::check()); view()->share('user', $this->loggedInUser); }
public function __construct() { /** * getting role permissions */ $this->auth = Auth::user(); if (Auth::check()) { $this->perms = get_role_permissions($this->auth, 'articles'); $this->perms = array_add($this->perms, count($this->perms), 'getCats'); $this->perms = array_add($this->perms, count($this->perms), 'getFields'); $this->perms = array_add($this->perms, count($this->perms), 'event'); $this->perms = array_add($this->perms, count($this->perms), 'getEvents'); $this->perms = array_add($this->perms, count($this->perms), 'brightCove'); $this->perms = array_add($this->perms, count($this->perms), 'getAjaxTags'); $this->perms = ['except' => $this->perms]; } else { $this->perms = guest_role_permissions('articles'); $this->perms = ['except' => $this->perms]; } //print_r(bcrypt($this->auth->password)); /** * Middlewares */ $this->middleware('auth', ['except' => ['show']]); $this->middleware('RedirectUser', ['except' => ['show']]); $this->middleware('role', $this->perms); $this->middleware('language'); }
public function getRegister() { if (Auth::check()) { return redirect('/content')->with('message', 'you are already logged in.'); } return view('auth.register'); }
public function vacations($vacation) { if ($vacation == 'winter') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Зима')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } elseif ($vacation == 'spring') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Весна')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } elseif ($vacation == 'summer') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Лето')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } elseif ($vacation == 'autumn') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Осень')->orderBy('programs.id', 'desc')->select('programs.id as id', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } elseif ($vacation == 'weekend') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Выходной')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } elseif ($vacation == 'festival') { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->where('vacations.season', '=', 'Фестиваль')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } else { $programs = Program::where('programs.active', '=', '1')->join('vacations', 'programs.id', '=', 'vacations.program_id')->orderBy('programs.id', 'desc')->select('programs.*', 'vacations.start_date as start_date', 'vacations.finish_date as finish_date')->get(); } $all_news = News::where('active', '=', '1')->get(); $monthes = array(1 => 'Января', 2 => 'Февраля', 3 => 'Марта', 4 => 'Апреля', 5 => 'Мая', 6 => 'Июня', 7 => 'Июля', 8 => 'Августа', 9 => 'Сентября', 10 => 'Октября', 11 => 'Ноября', 12 => 'Декабря'); if (Auth::check()) { $user = Auth::user()->name; } else { $user = '******'; } return view('index', ['programs' => $programs, 'monthes' => $monthes, 'all_news' => $all_news, 'user' => $user]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { if (Auth::check()) { $user = Auth::user(); return view('pages.compte.index', compact('user', 'rsx')); } }
/** * @return mixed */ public function showNews() { $slug = Request::segment(2); $news_title = "Not active"; $news_text = "Either this news item is not active, or it does not exist"; $active = 1; $news_id = 0; $results = DB::table('news')->where('slug', '=', $slug)->get(); foreach ($results as $result) { $active = $result->active; if ($active > 0 || Auth::check() && Auth::user()->hasRole('news')) { if (Session::get('lang') == null || Session::get('lang') == "en") { $news_title = $result->title; $news_text = $result->news_text; $news_id = $result->id; } else { $news_title = $result->title_fr; $news_text = $result->news_text_fr; $news_id = $result->id; } $news_image = $result->image; $news_date = $result->news_date; } } return View::make('public.news')->with('news_title', $news_title)->with('news_text', $news_text)->with('page_content', $news_text)->with('active', $active)->with('news_id', $news_id)->with('news_date', $news_date)->with('news_image', $news_image)->with('menu', $this->menu)->with('page_category_id', 0)->with('page_title', $news_title); }
/** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string $role * @return mixed */ public function handle($request, Closure $next, $role) { if (Auth::check() && Auth::user()->UserRoles->role >= $role) { return $next($request); } return redirect::to('/admin/login'); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { if (Auth::check()) { return Redirect::to('/profile'); } return View::make('user-package::registration.create'); }
public function getLogin() { if (Auth::check()) { return Redirect::to('/'); } return view('auth.login'); }
public function registration() { if (Auth::check()) { return redirect('dashboard'); } return view('registration'); }
/** * Register the service provider. * * @return void */ public function register() { $this->app['router']->before(function ($request) { // First clear out all "old" visitors Visitor::clear(); $page = Request::path(); $ignore = Config::get('visitor-log::ignore'); if (is_array($ignore) && in_array($page, $ignore)) { //We ignore this site return; } $visitor = Visitor::getCurrent(); if (!$visitor) { //We need to add a new user $visitor = new Visitor(); $visitor->ip = Request::getClientIp(); $visitor->useragent = Request::server('HTTP_USER_AGENT'); $visitor->sid = str_random(25); } $user = null; $usermodel = strtolower(Config::get('visitor-log::usermodel')); if (($usermodel == "auth" || $usermodel == "laravel") && Auth::check()) { $user = Auth::user()->id; } if ($usermodel == "sentry" && class_exists('Cartalyst\\Sentry\\SentryServiceProvider') && Sentry::check()) { $user = Sentry::getUser()->id; } //Save/Update the rest $visitor->user = $user; $visitor->page = $page; $visitor->save(); }); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!Auth::check() || !Auth::user()->admPower) { return redirect()->route('paginaInicial'); } return $next($request); }
public function getLogout() { if (Auth::check()) { Auth::logout(); } return Redirect::to('index')->with('message', '你现在已经退出登录了!'); }