/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         return Redirect::home();
     }
     return $next($request);
 }
 /**
  * @param Requests\SignUpRequest $request
  * @param CommandDispatcher $commandDispatcher
  *
  * @return
  */
 public function store(Requests\SignUpRequest $request, CommandDispatcher $commandDispatcher)
 {
     $commandDispatcher->dispatchFrom(RegisterUser::class, $request);
     \Auth::login(User::where('username', $request['username'])->first());
     Flash::overlay('Welcome!!');
     return Redirect::home();
 }
 public function destroy($id)
 {
     $user = $this->userRepository->findById($id);
     if ($this->userRepository->delete($user)) {
         return Redirect::home()->with('success', 'word.deleted');
     }
     return Redirect::back('/')->with('errors', 'word.error');
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $headline = Headline::where('uid', $id)->first();
     if ($headline) {
         return view('headline', ['headline' => $headline]);
     }
     return Redirect::home();
 }
 public function store()
 {
     $this->registrationForm->validate(Input::all());
     $user = $this->execute(RegisterUserCommand::class);
     Auth::login($user);
     Flash::overlay('WELCOME! Glad to have you as a new Larabook member!');
     return Redirect::home();
 }
 /**
  * Show the Administrator panel.
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     try {
         $user = Auth::user()->with('projects')->where('id', '=', '2')->firstOrFail();
     } catch (ModelNotFoundException $e) {
         return Redirect::home();
     }
     // if it's admin, redirect to admin cms with all users but admin
     $allUsers = User::whereNotIn('id', [2])->get();
     $allSponsors = Sponsor::all();
     // Retrieve all projects pending approval.
     $pendingProjects = Project::where('approved', '=', '0')->where('application_status', '=', '1')->where('live', '=', '0')->get();
     return view('adminpanel.index', compact('user', 'allUsers', 'pendingProjects', 'allSponsors'));
 }
Example #7
0
 /**
  * Logs the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function loginPost()
 {
     $loginData = Request::only(['login', 'password']);
     // Login with username or email.
     $loginKey = Str::contains($loginData['login'], '@') ? 'email' : 'username';
     $loginData[$loginKey] = array_pull($loginData, 'login');
     // Validate login credentials.
     if (Auth::validate($loginData)) {
         // Log the user in for one request.
         Auth::once($loginData);
         // We probably want to add support for "Remember me" here.
         Auth::attempt($loginData);
         //return Redirect::intended('/')
         return Redirect::home()->withSuccess(trans('gitamin.signin.success'));
     }
     return Redirect::route('auth.login')->withInput(Request::except('password'))->withError(trans('gitamin.signin.invalid'));
 }
 /**
  *
  */
 public function getLogout()
 {
     Auth::logout();
     return Redirect::home();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store()
 {
     $user = User::create(Input::only('username', 'email', 'password'));
     Auth::login($user);
     return Redirect::home();
 }
Example #10
0
 /**
  * generates an error response when the model is not found or redirects home with an error
  *
  * @param String $message the message to print
  * @return Response
  */
 protected function modelNotFoundError($message = 'elemento non trovato')
 {
     $data = array('error' => true, 'message' => $message);
     if ($this->isAjaxRequest()) {
         return $this->jsonResponse($data, 404);
     }
     return Redirect::home()->with('error', $message);
 }
 /**
  * Validate the ownership of a route.
  *
  * @param Route        $route
  * @param string       $parameter
  * @param string|array $fields
  *
  * @return \Illuminate\Http\RedirectResponse|null
  */
 protected function validateOwnership($route, $parameter, $fields = 'user_id')
 {
     $fields = (array) $fields;
     if (Auth::check()) {
         $user = Auth::user();
         // Gather fields
         $model = $route->getParameter($parameter);
         if (!$model) {
             return;
         }
         foreach ($fields as $key => $field) {
             $fields[$key] = $model->{$field};
         }
         // Validate ownership
         if ($model and !in_array($user->id, $fields)) {
             return Redirect::home();
         }
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id = null)
 {
     Auth::logout();
     return Redirect::home();
 }
Example #13
0
 /**
  * Get all queries by route.
  */
 protected function getQueries()
 {
     $crawler = $this->getCrawler();
     // Spoof Redirect::back
     $endpoint = Redirect::home();
     Redirect::shouldReceive('to')->andReturn($endpoint);
     Redirect::shouldReceive('back')->andReturn($endpoint);
     // Create Client
     $this->laravel['auth']->loginUsingId($this->user);
     $client = new Client($this->laravel, []);
     // Crawl routes
     $routes = $crawler->getRoutes();
     $this->info('Found ' . count($routes) . ' routes');
     foreach ($routes as $route) {
         $this->inspect($client, $route);
     }
 }
 /**
  * Display the specified resource.
  *
  * @param $username
  * @internal param int $id
  * @return Response
  */
 public function show($username)
 {
     try {
         $user = Auth::user()->with('projects')->where('user_name', $username)->firstOrFail();
     } catch (ModelNotFoundException $e) {
         return Redirect::home();
     }
     // Take the Administrator to the admin panel.
     if ($user->id == '2') {
         return redirect('admin');
     }
     $contributions = Pledge::where('user_id', '=', $user->id)->get();
     $favourites = Favourite::with('project')->where('user_id', '=', $user->id)->get();
     // if it's a regular user, redirect to user's dashboard
     return view('userpanel.index', compact('user', 'contributions', 'favourites'));
 }
Example #15
0
 /**
  * Log a user out of larabook.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy()
 {
     Auth::logout();
     Flash::message('You have now been logged out.');
     return Redirect::home();
 }
 public function activaCorreo(Request $request, $correo, $hash)
 {
     $user = \App\User::where('email', '=', $correo)->first();
     if (md5($user->password) == $hash) {
         $user->activo = 1;
         $user->save();
         return Redirect::home()->with('message', '¡Bienvenido! Gracias por ser parte de Ventana Educativa. Ahora puedes iniciar sesión');
         //            return view('viewVentana/activacionCorrecta');
     } else {
         print 'error';
     }
 }
Example #17
0
 /**
  * Remove the specified role from storage.
  *
  * @param RoleInterface $role
  * @internal param int $id
  * @return Response
  */
 public function destroy(RoleInterface $role)
 {
     $response = null;
     $user = $this->getUser();
     if ($user->can('delete', $role)) {
         if ($this->role_repository->delete($role)) {
             $response = Redirect::route('roles.role.index')->with('success', trans('roles::role.delete_success'));
         } else {
             $response = Redirect::back()->withErrors($this->role_repository->getErrors());
         }
     } else {
         $response = Redirect::home();
     }
     return $response;
 }
Example #18
0
 /**
  * Called after form has been submitted. This prepares collected data for writing to
  * source files and sets the member variable $formData
  *
  * @param array $formData
  *
  * @return $this
  */
 public function setFormData(array $formData = [])
 {
     $_facterData = ['INSTALLER_FACTS' => 1];
     $_cleanData = [];
     if (empty($formData) || count($formData) < 5) {
         /** @noinspection PhpUndefinedMethodInspection */
         Session::flash('failure', 'Not all required fields were completed.');
         /** @noinspection PhpUndefinedMethodInspection */
         Log::error('Invalid number of post entries: ' . print_r($formData, true));
         /** @noinspection PhpUndefinedMethodInspection */
         Redirect::home();
     }
     //  Remove CSRF token
     array_forget($formData, '_token');
     //  Add in things that don't exist in form...
     $formData['dc-es-exists'] = array_key_exists('dc-es-exists', $formData) ? 'true' : 'false';
     $formData['dc-es-cluster'] = array_get($formData, 'dc-es-cluster', $this->defaults['dc_es_cluster']);
     $formData['dc-es-port'] = array_get($formData, 'dc-es-port', $this->defaults['dc_es_port']);
     $formData['dc-port'] = array_get($formData, 'dc-port', $this->defaults['dc_port']);
     $formData['dc-client-port'] = array_get($formData, 'dc-client-port', $this->defaults['dc_client_port']);
     //  Check for non-existent host name
     if (empty(array_get($formData, 'dc-host'))) {
         $formData['dc-host'] = implode('.', [$this->defaults['console_host_name'], trim(array_get($formData, 'vendor-id')), trim(array_get($formData, 'domain'))]);
     }
     //  Clean up the keys for factering
     foreach ($formData as $_key => $_value) {
         $_value = trim($_value);
         $_cleanKey = trim(str_replace('-', '_', $_key));
         //  Clean up any diabolical leading slashes on values
         switch ($_cleanKey) {
             case 'storage_path':
                 $_storagePath = $_value = trim($_value, DIRECTORY_SEPARATOR);
                 break;
             case 'mount_point':
                 $_mountPoint = $_value = rtrim($_value, DIRECTORY_SEPARATOR);
                 break;
             case 'dc_host':
                 //  Copy DC host to DC client host
                 $_facterData['export FACTER_DC_CLIENT_HOST'] = $_value;
                 break;
         }
         //  Dump non-empties into the source file
         if (null !== $_value) {
             $_facterData['export FACTER_' . strtoupper($_cleanKey)] = $_value;
         }
         //  Keep a pristine copy
         $_cleanData[$_cleanKey] = $_value;
         //  Save cleaned value, if any
         $formData[$_key] = $_value;
         unset($_cleanKey, $_key, $_value);
     }
     //  If set have a storage and mount, construct a storage path
     if (!empty($_storagePath) && !empty($_mountPoint)) {
         $_cleanData['storage_mount_point'] = $_facterData['export FACTER_STORAGE_MOUNT_POINT'] = Disk::path([$_mountPoint, $_storagePath]);
     }
     $this->formData = $formData;
     $this->cleanData = $_cleanData;
     $this->facterData = $_facterData;
     logger('Form data set: ' . print_r($this->formData, true));
     logger('Clean data set: ' . print_r($this->cleanData, true));
     logger('Facter data set: ' . print_r($this->facterData, true));
     return $this;
 }