/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param Closure|\Closure $next
  * @param $permissions
  * @return mixed
  * @internal param $roles
  * @internal param null|string $guard
  */
 public function handle(Request $request, Closure $next, $permissions)
 {
     if (Auth::guest() || !$request->user()->can(explode('|', $permissions))) {
         abort(403);
     }
     return $next($request);
 }
 public function slots()
 {
     $user = Auth::user();
     $location = $user->location;
     $slot = Slot::where('location', '=', $location)->first();
     $input = Input::get('wager');
     $owner = User::where('name', '=', $slot->owner)->first();
     $num1 = rand(1, 10);
     $num2 = rand(5, 7);
     $num3 = rand(5, 7);
     if ($user->name != $owner->name) {
         if ($num1 & $num2 & $num3 == 6) {
             $money = rand(250, 300);
             $payment = $money += $input * 1.75;
             $user->money += $payment;
             $user->save();
             session()->flash('flash_message', 'You rolled three sixes!!');
             return redirect('/home');
         } else {
             $user->money -= $input;
             $user->save();
             $owner->money += $input;
             $owner->save();
             session()->flash('flash_message_important', 'You failed to roll three sixes!!');
             return redirect(action('SlotsController@show', [$slot->location]));
         }
     } else {
         session()->flash('flash_message_important', 'You own this slot!!');
         return redirect(action('SlotsController@show', [$slot->location]));
     }
 }
Example #3
0
 public function store()
 {
     $this->record = new Activity(array_merge(Request::all(), ['adder_id' => Auth::User()->id, 'modifier_id' => Auth::User()->id]));
     try {
         switch ($this->related_type) {
             case 'lead':
                 $this->relatedObj = new \App\Lead();
                 break;
             case 'contact':
                 $this->relatedObj = new \App\Contact();
                 break;
             case 'account':
                 $this->relatedObj = new \App\Account();
                 break;
             case 'opportunity':
                 $this->relatedObj = new \App\Opportunity();
                 break;
             default:
         }
         $obj = $this->relatedObj->find($this->related_id);
         if ($this->validated()) {
             $obj->activities()->save($this->record);
         }
     } catch (\Exception $e) {
         Session::flash('pageError', 'Error saving activity.' . $e->getMessage());
         return View('activity/activity-new', ['record' => $this->record, 'relates_to' => $this->relates_to]);
     }
     $redirectURL = Request::input('action') == 'saveNew' ? '/activity/create?related_type=' . $this->related_type . '&related_id=' . $this->related_id : '/' . $this->related_type . '/' . $this->related_id;
     return redirect($redirectURL)->with('pageSuccess', 'Activity saved successfully.');
 }
Example #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param AdduserRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(AdduserRequest $request)
 {
     //        $input = $request->all();                               // get all data
     //        $input['confirmed'] = 1;                                // set confirmed to 1
     //        $input['password'] = Hash::make($input['password']);    // hash password
     //
     //        $user       =   User::create($input);                   // save above details
     $user = User::create(['first_name' => $request->first_name, 'last_name' => $request->last_name, 'email' => $request->email, 'confirmed' => 1, 'password' => Hash::make($request->password)]);
     //        $profile    =   $user->profile()->save(new Profile);    // also create new profile
     //        $profile->apartment_id  =   Auth::user()->profile->defaultApartment; // get current defaultApartment
     //        $profile->save();                                       // save details on profile
     $profile = Profile::create(['user_id' => $user->id, 'apartment_id' => Auth::user()->profile->defaultApartment]);
     dd(Auth::user()->profile->defaultApartment);
     $role = Role::whereName('user')->first();
     $user->assignRole($role);
     //Assign Role
     $block_no = $request->blockno;
     // get block_no from profileform
     $floor_no = $request->floorno;
     // get floor_no from profileform
     $profile->apartments()->attach($profile->defaultApartment, ['approved' => '1', 'block_no' => $block_no, 'floor_no' => $floor_no]);
     // attach this profile with default apartment, with approved = 1, and block_no, floor_no according to profileform in apartment_profile pivot table.
     Crm_account::create(['account' => $user->first_name . $user->last_name, 'fname' => $user->first_name, 'lname' => $user->last_name, 'company' => 'Company Name', 'email' => $user->email, 'address' => 'Current Address', 'city' => 'Nagpur', 'state' => 'Maharashtra', 'zip' => '440012', 'country' => 'India']);
     return redirect()->back()->withMessage('User has been Added')->withStatus('success');
 }
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $validation['password'] = '******';
     $validation['current_password'] = '******';
     $user = Auth::user();
     return $validation;
 }
Example #6
0
 public function update()
 {
     $profile = Profile::where('user_id', Auth::user()->id)->first();
     $profile->fill(Input::all());
     $profile->save();
     return Redirect::to("/edit_profile");
 }
Example #7
0
 /**
  * @param $credentials
  * @throws ValidationFailed
  */
 public function validate($credentials)
 {
     $valid = Auth::validate($credentials);
     if (!$valid) {
         throw new ValidationFailed();
     }
 }
 /**
  * Boot Oci8 Provider
  */
 public function boot()
 {
     $this->publishes([__DIR__ . '/../config/oracle.php' => config_path('oracle.php')], 'oracle');
     Auth::provider('oracle', function ($app, array $config) {
         return new OracleUserProvider($app['hash'], $config['model']);
     });
 }
Example #9
0
 /**
  * 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);
 }
Example #10
0
 public function callback(SocialAccountService $service, $provider)
 {
     $driver = Socialite::driver($provider);
     $user = $service->createOrGetUser($driver, $provider);
     Auth::login($user, true);
     return redirect()->intended('/');
 }
Example #11
0
 public function dashboard()
 {
     $messages = Redis::lrange('messages', 0, -1);
     $messages = $messages ? $messages : [];
     $tasks = Auth::user()->tasks()->get();
     return view('dashboard', compact('messages', 'tasks'));
 }
 /**
  * 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 edit(Donations $donations)
 {
     if (!Auth::check()) {
         return redirect('donations');
     }
     return view('edit', compact('donations'));
 }
Example #14
0
 /**
  * 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::user()->id == 1) {
         return $next($request);
     }
     return redirect()->guest('login')->withErrors(trans('auth.admin'));
 }
Example #15
0
 /**
  * Process a login HTTP POST
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postLogin(Request $request)
 {
     //TODO
     // dd($request->all());
     //\Debugbar::info("Entra postlogin");
     //echo "prova";
     $this->validate($request, ['email' => 'required|email', 'password' => 'required']);
     //        if($this->login($request->email, $request->password)){
     //            //REDIRECT TO HOME
     //            //Session::set('authenticated',true);
     //
     //            return redirect()->route('auth.home');
     //        }else{
     //            $request->session()->flash('login_error', 'Login Incorrecte');
     //            return redirect()->route('auth.login');
     //            //REDIRECT BACK
     //        }
     if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
         // Authentication passed...
         return redirect()->route('auth.home');
         //return redirect()->intended('auth.home');
     } else {
         return redirect()->route('auth.login');
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Auth::user()) {
         Cache::forever('last_seen_' . Auth::user()->id, date('Y-m-d H:i:s'));
     }
     return $next($request);
 }
Example #17
0
 public function postLogin(\Illuminate\Http\Request $request)
 {
     $username = $request->input('username');
     $password = $request->input('password');
     // First try to log in as a local user.
     if (Auth::attempt(array('username' => $username, 'password' => $password))) {
         $this->alert('success', 'You are now logged in.', true);
         return redirect('users/' . Auth::user()->id);
     }
     // Then try with ADLDAP.
     $ldapConfig = \Config::get('adldap');
     if (array_get($ldapConfig, 'domain_controllers', false)) {
         $adldap = new \adldap\adLDAP($ldapConfig);
         if ($adldap->authenticate($username, $password)) {
             // Check that they exist.
             $user = \Ormic\Model\User::where('username', '=', $username)->first();
             if (!$user) {
                 $user = new \Ormic\Model\User();
                 $user->username = $username;
                 $user->save();
             }
             \Auth::login($user);
             //$this->alert('success', 'You are now logged in.', TRUE);
             return redirect('');
             //->with(['You are now logged in.']);
         }
     }
     // If we're still here, authentication has failed.
     return redirect()->back()->withInput($request->only('username'))->withErrors(['Authentication failed.']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $template = new Template($request->all());
     $template->user_id = Auth::user()->id;
     $template->save();
     return Redirect::route('templates.index');
 }
Example #19
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function newComment(CommentFormRequest $request)
 {
     $user_id = Auth::user()->id;
     $comment = new Comment(array('post_id' => $request->get('post_id'), 'content' => $request->get('content'), 'user_id' => $user_id));
     $comment->save();
     return redirect()->back()->with('custom_success', 'Your comment has been created!');
 }
Example #20
0
 /**
  * @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');
 }
 /**
  * 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)->check()) {
         return redirect('searches');
     }
     return $next($request);
 }
 /**
  * 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)
 {
     // Check for the guard and redirect accordingly
     if (Auth::guard($guard)->guest()) {
         if ($request->ajax() || $request->wantsJson()) {
             return response('Unauthorized.', 401);
         } elseif ($guard == 'student') {
             return redirect()->guest('/students/login');
         } elseif ($guard == 'teacher') {
             return redirect()->guest('/teachers/login');
         } elseif ($guard == 'hostelStaff') {
             return redirect()->guest('/hostelStaffs/login');
         } elseif ($guard == 'libraryStaff') {
             return redirect()->guest('/libraryStaffs/login');
         } elseif ($guard == 'departmentStaff') {
             return redirect()->guest('/departmentStaffs/login');
         } elseif ($guard == 'chiefWardenStaff') {
             return redirect()->guest('/chiefWardenStaffs/login');
         } elseif ($guard == 'adminStaff') {
             return redirect()->guest('/adminStaffs/login');
         } elseif ($guard == 'admin') {
             return redirect()->guest('/admins/login');
         }
     }
     return $next($request);
 }
 /**
  * Register any application authentication / authorization services.
  *
  * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
  * @return void
  */
 public function boot(GateContract $gate)
 {
     $this->registerPolicies($gate);
     Auth::extend('api_token', function ($app, $name, array $config) {
         return new ApiTokenGuard(Auth::createUserProvider($config['provider']), $this->app['request']);
     });
 }
 public function store(Requests\ArticleRequest $request)
 {
     // Validation:
     $article = new Article($request->all());
     Auth::user()->articles()->save($article);
     return redirect('articles');
 }
Example #25
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom));
         $model->effectiveto = date('Y-m-d', strtotime($model->effectiveto));
         $model->createdby = Auth::user()->id;
         $model->createddate = date("Y-m-d H:i:s");
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::created(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
     static::updating(function ($model) {
         $model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom));
         $model->effectiveto = date('Y-m-d', strtotime($model->effectiveto));
         $model->modifiedby = Auth::user()->id;
         $model->modifieddate = date("Y-m-d H:i:s");
     });
     static::updated(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
     static::deleted(function ($model) {
         Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
     });
 }
Example #26
0
 /**
  * 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::guest()) {
         return redirect('login');
     }
     return $next($request);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $todo = new Todo(Request::all());
     $todo->user_id = Auth::user()->id;
     $todo->save();
     return $todo;
 }
Example #28
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = Auth::user();
     $pusher = new Pusher(Config::get('services.pusher.key'), Config::get('services.pusher.secret'), Config::get('services.pusher.id'));
     $pusher->trigger('my-channel', 'my-event', array('message' => $user->name . ': ' . Input::get('msg'), 'user_id' => $user->id));
     return 'done';
 }
Example #29
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Auth::user() || Auth::user()->id !== 1) {
         return redirect('/');
     }
     return $next($request);
 }
 public function main(Request $request)
 {
     switch ($request->data) {
         case "courses":
             $courses = Course::all();
             foreach ($courses as $course) {
                 $course["status"] = $course->seatsStatus();
                 $course["enrolled"] = $course->totalEnrolled();
                 $course["waitlist"] = $course->totalWaitlisted();
             }
             return response()->json(['courses' => $courses]);
         case "gpa":
             if ($request->has('student_id')) {
                 $student = User::find($request->get('student_id'));
                 return $student->gpa();
             } else {
                 return [];
             }
         case "classestaken":
             return Auth::user()->pastClasses();
         case "activecodes":
             $section_id = $request->get('section_id');
             return Auth::user()->returnActiveCodes($section_id);
         case "generateaddcode":
             $section_id = $request->get('section_id');
             Auth::user()->generateAddCode($section_id);
             return redirect()->action('CoursesController@addCode');
         default:
             return "no data specified";
     }
 }