Beispiel #1
0
 /**
  * @param array $settings
  */
 public function __construct($settings)
 {
     $this->container = \Chubby\AppFactory::getApp()->getSlim()->getContainer();
     if (!isset($settings['urlRoot'])) {
         throw new \Exception("Missing urlRoot.");
     }
     if (substr($settings['urlRoot'], -1) == '/') {
         $settings['urlRoot'] = substr($settings['urlRoot'], 0, -1);
     }
     $this->urlRoot = $settings['urlRoot'];
     // Setup Cartalyst's Sentinel
     if (!isset($settings['database'])) {
         throw new \Exception("Missing database connection parameters.");
     }
     $this->capsule = new Capsule();
     $this->capsule->addConnection($settings['database']);
     $this->capsule->bootEloquent();
     // We use a closure to reference the sentinel object so
     // the object itself isn't created until the first time it's needded.
     // This is IMPORTANT because because native installations of Sentinel, by using
     // Symfony's HttpFoundation's Request object, will consume the php://input stream.
     // If Symfony's object gets to consume the stream before Slim, we won't be able to
     // get any input from it.
     // So, we MUST make sure that Sentinel getter (getSentinel()) is executed AFTER
     // Slim has processed the request, hence read the php://input stream.
     $this->sentinel = function () {
         static $obj = null;
         if ($obj == null) {
             $obj = Sentinel::instance()->getSentinel();
         }
         return $obj;
     };
 }
Beispiel #2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Sentinel::check()) {
         return redirect('/');
     }
     return $next($request);
 }
 /**
  * Run Method.
  *
  * Write your database seeder using this method.
  *
  * More information on writing seeders is available here:
  * http://docs.phinx.org/en/latest/seeding.html
  */
 public function run()
 {
     $capsule = new \Illuminate\Database\Capsule\Manager();
     $capsule->addConnection(['driver' => 'sqlite', 'database' => __DIR__ . '/../../data/database.db']);
     $capsule->bootEloquent();
     \Cartalyst\Sentinel\Native\Facades\Sentinel::registerAndActivate(['email' => '*****@*****.**', 'password' => 'password']);
 }
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request        	
  * @param \Closure $next        	
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //dd(Sentinel::check());
     if ($user = Sentinel::check()) {
         return new RedirectResponse(url('/home'));
     }
     return $next($request);
 }
function register_valid()
{
    $credentials = ["email" => $_POST["email"]];
    if (!Sentinel::getUserRepository()->findByCredentials($credentials)) {
        return true;
    }
    return false;
}
Beispiel #6
0
 /**
  * Handle dynamic, static calls to the object.
  *
  * @param  string  $method
  * @param  array  $args
  * @return mixed
  */
 public function __call($method, $args)
 {
     $instance = $this->sentinel->__invoke();
     switch (count($args)) {
         case 0:
             return $instance->{$method}();
         case 1:
             return $instance->{$method}($args[0]);
         case 2:
             return $instance->{$method}($args[0], $args[1]);
         case 3:
             return $instance->{$method}($args[0], $args[1], $args[2]);
         case 4:
             return $instance->{$method}($args[0], $args[1], $args[2], $args[3]);
         default:
             return call_user_func_array([$instance, $method], $args);
     }
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     if (Sentinel::hasAccess('depositos.view')) {
         $deposito = new Deposito();
         return view('contabilidad::Deposits.index', compact('deposito'));
     } else {
         alert()->error('No tiene permisos para acceder a esta area.', 'Oops!')->persistent('Cerrar');
         return back();
     }
 }
Beispiel #8
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     if (Sentinel::hasAccess('test.create')) {
         $test = Test::find($id);
         return view('PackageTest::test.create', compact('test'));
     } else {
         // Execute this code if the permission check failed
         return back()->withErrors('No tiene permisos para acceder a esta area.');
     }
 }
Beispiel #9
0
 public function run()
 {
     \DB::table('users')->truncate();
     \DB::table('roles')->truncate();
     \DB::table('role_users')->truncate();
     $role = ['name' => 'Administrator', 'slug' => 'administrator', 'permissions' => ['user.view' => true, 'user.create' => true, 'user.update' => true, 'user.delete' => true, 'role.view' => true, 'role.create' => true, 'role.update' => true, 'role.delete' => true, 'role.permissions' => true]];
     $adminRole = Sentinel::getRoleRepository()->createModel()->fill($role)->save();
     $admin = ['email' => '*****@*****.**', 'password' => 'test', 'image' => 'avatar-larus.jpeg', 'position' => 'Administrador', 'first_name' => 'Admin', 'last_name' => 'example'];
     $adminUser = Sentinel::registerAndActivate($admin);
     $adminUser->roles()->attach($adminRole);
 }
Beispiel #10
0
 public function firstRun()
 {
     if (!$this->app->helperService->isFirstRun()) {
         $this->app->notFound();
     }
     if ($this->app->request->isPost()) {
         $credentials = ['email' => $this->app->request->post('email'), 'password' => $this->app->request->post('password')];
         $user = Sentinel::registerAndActivate($credentials);
         Sentinel::loginAndRemember($user);
         $this->app->redirectTo('contentList');
     }
     $this->app->render('register.twig');
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Sentinel::check()) {
         if (Sentinel::hasAccess('cuentas.view')) {
             $cuentas = Cuentas::all();
             $cuentas->load('bancom');
             return view('contabilidad::Cuentas.index', compact('cuentas'));
         }
         alert()->error('No tiene permisos para acceder a esta area.', 'Oops!')->persistent('Cerrar');
         return back();
     } else {
         return redirect('login');
     }
 }
Beispiel #12
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request        	
  * @param \Closure $next        	
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //dd(Sentinel::guest());
     //Sentinel::logout();
     //dd(Sentinel::guest());
     if (Sentinel::guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest('auth/login');
         }
     }
     return $next($request);
 }
Beispiel #13
0
 public function index()
 {
     if (Sentinel::check()) {
         if (Sentinel::hasAccess('cancelaciones.view')) {
             $plazas = Place::plazasArray($this->user_auth->id);
             return view('contabilidad::Cancel.index', compact("plazas"));
         } else {
             alert()->error('No tiene permisos para acceder a esta area.', 'Oops!')->persistent('Cerrar');
             return back();
         }
     } else {
         return redirect('login');
     }
 }
Beispiel #14
0
 public function compose(View $view)
 {
     $array_task = [];
     $array_alert = [];
     $array_notification = [];
     $tasks_count = 0;
     $alerts_count = 0;
     $notifications_count = 0;
     //menus
     $packages = Package::with('modules')->get();
     //datas of the user logged
     $userAuth = Sentinel::getUser();
     $today = Carbon::now();
     //  tareas
     $tasks = Task::where('user_id', '=', $userAuth->id)->orwhere('role_id', '=', $userAuth->roles[0]->id)->orderBy('created_at', 'DESC')->get();
     foreach ($tasks as $task) {
         if (is_null($task->read)) {
             array_push($array_task, $task);
             $tasks_count++;
         } elseif (!in_array($userAuth->id, unserialize($task->read))) {
             array_push($array_task, $task);
             $tasks_count++;
         }
     }
     //  alertas
     $alerts = Task::where('expire_time', '<', $today)->Where(function ($query) use($userAuth) {
         $query->where('user_id', '=', $userAuth->id)->orwhere('role_id', '=', $userAuth->roles[0]->id);
     })->with('hasAlert')->get();
     foreach ($alerts as $alert) {
         if (is_null($alert->hasAlert[0]->alert_display)) {
             array_push($array_alert, $alert);
             $alerts_count++;
         } elseif (!in_array($userAuth->id, unserialize($alert->hasAlert[0]->alert_display))) {
             array_push($array_alert, $alert);
             $alerts_count++;
         }
     }
     //  notifications
     $notifications = Notification::where('user_id', '=', $userAuth->id)->orwhere('role_id', '=', $userAuth->roles[0]->id)->get();
     foreach ($notifications as $notification) {
         if (is_null($notification->read)) {
             array_push($array_notification, $notification);
             $notifications_count++;
         } elseif (!in_array($userAuth->id, unserialize($notification->read))) {
             array_push($array_notification, $notification);
             $notifications_count++;
         }
     }
     $view->with(array('packages' => $packages, 'userAuth' => $userAuth, 'alerts' => $array_alert, 'alerts_count' => $alerts_count, 'notifications' => $array_notification, 'notifications_count' => $notifications_count, 'tasks' => $array_task, 'tasks_count' => $tasks_count));
 }
 public function index()
 {
     if (Sentinel::check()) {
         if (Sentinel::hasAccess('polizas.view')) {
             $fechaAyer = Carbon::now()->subDay()->format('Y/m/d');
             $plazas = Place::plazasArray($this->user_auth->id);
             return view('contabilidad::Policies.form', compact('plazas', 'fechaAyer'));
         } else {
             alert()->error('No tiene permisos para acceder a esta area.', 'Oops!')->persistent('Cerrar');
             return back();
         }
     } else {
         return redirect('login');
     }
 }
 public function index()
 {
     if (Sentinel::check()) {
         if (Sentinel::hasAccess('antiguedad.view')) {
             $fechaActual = Carbon::now()->format('Y/m/d');
             $payment_methods = PaymentMethod::all();
             $plazas = Place::plazasArray($this->user_auth->id);
             return view('contabilidad::OldBalance.form', compact("payment_methods", "plazas", "fechaActual"));
         } else {
             alert()->error('No tiene permisos para acceder a esta area.', 'Oops!')->persistent('Cerrar');
             return back();
         }
     } else {
         return redirect('login');
     }
 }
Beispiel #17
0
 /**
  * Создаем тестовых пользователей
  */
 public function run()
 {
     $this->command->info('Создаем пользователя: Администратор');
     $credentials = array('email' => '*****@*****.**', 'password' => 'admin1111', 'first_name' => 'Иван', 'last_name' => 'Петров', 'company' => 'Такси-сервис', 'city' => 'г. Вологда', 'phone' => '+7 (911) 501-55-55');
     $user = Sentinel::register($credentials);
     $role = Sentinel::findRoleBySlug('admin');
     $role->users()->attach($user);
     // Добавляем оператора
     Operator::create(array('user_id' => $user->id, 'name' => $user->first_name . ' ' . $user->last_name));
     $this->command->info('Создаем пользователя: Тестовый');
     $credentials = array('email' => '*****@*****.**', 'password' => 'admin1111', 'first_name' => 'Екатерина', 'last_name' => 'Климова', 'company' => 'Белка тур', 'city' => 'г. Вологда', 'phone' => '+7 (911) 233-33-33');
     $user = Sentinel::register($credentials);
     $role = Sentinel::findRoleBySlug('user');
     $role->users()->attach($user);
     // Добавляем оператора
     Operator::create(array('user_id' => $user->id, 'name' => $user->first_name . ' ' . $user->last_name));
 }
Beispiel #18
0
 /**
  * Handle posting of the form for the user registration.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function processRegistration(Request $request)
 {
     $input = $request->all();
     $rules = ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required', 'retype_password' => 'required|same:password'];
     $validator = \Validator::make($input, $rules);
     if ($validator->fails()) {
         return \Redirect::back()->withInput()->withErrors($validator);
     }
     if ($user = Sentinel::register($input)) {
         $activation = Activation::create($user);
         $code = $activation->code;
         if (Activation::complete($user, $code)) {
             return \Redirect::to('login')->withSuccess('Your accout was successfully created. You might login now.')->with('userId', $user->getUserId());
         }
     }
     return \Redirect::to('register')->withInput()->withErrors('Failed to register.');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $permissions = Module::with('permissions')->get();
     // find role by id
     $role = Sentinel::findRoleById($id);
     // inputs
     $data = $request->get('data');
     $value = $request->get('value');
     if (isset($role->permissions[$value])) {
         $role->updatePermission($value, $data == 'true' ? true : false);
         $role->save();
         return "update";
     } else {
         $role->addPermission($value, $data == 'true' ? true : false);
         $role->save();
         return "add";
     }
 }
Beispiel #20
0
 /**
  * @param array $settings
  */
 public function __construct($settings)
 {
     $this->container = \Chubby\AppFactory::getApp()->getSlim()->getContainer();
     if (!isset($settings['urlRoot'])) {
         throw new \Exception("Missing urlRoot.");
     }
     if (substr($settings['urlRoot'], -1) == '/') {
         $settings['urlRoot'] = substr($settings['urlRoot'], 0, -1);
     }
     $this->urlRoot = $settings['urlRoot'];
     // Setup Cartalyst's Sentinel
     if (!isset($settings['database'])) {
         throw new \Exception("Missing database connection parameters.");
     }
     $this->capsule = new Capsule();
     $this->capsule->addConnection($settings['database']);
     $this->capsule->bootEloquent();
     $this->sentinel = Sentinel::instance()->getSentinel();
 }
 public function index()
 {
     if (Sentinel::check()) {
         if (Sentinel::hasAccess('pendientes.view')) {
             $usuario = User::find($this->user_auth->id);
             $oficinas = array();
             foreach ($usuario->plazas as $plazas) {
                 array_push($oficinas, $plazas->Oficina);
             }
             DB::enableQueryLog();
             $ventasPendientes = Sales::select('*', DB::raw('SUM(ammount) as ammount, SUM(ammount_applied) as ammount_applied '))->whereRaw('credit_debit = ?  ', ['credit'])->groupBy('reference')->get();
             return view('contabilidad::Earrings.index', compact("ventasPendientes"));
         } else {
             alert()->error('No tiene permisos para acceder a esta area.', 'Oops!')->persistent('Cerrar');
             return back();
         }
     } else {
         return redirect('login');
     }
 }
Beispiel #22
0
 public function index()
 {
     if (Sentinel::check()) {
         if (Sentinel::hasAccess('ventas.view')) {
             $usuario = User::find($this->user_auth->id);
             $oficinas = array();
             foreach ($usuario->plazas as $plazas) {
                 array_push($oficinas, $plazas->Oficina);
             }
             $salesLogs = SalesLog::whereIn('op_location', $oficinas)->orWhere(function ($query) use($oficinas) {
                 $query->whereIn('cl_location', $oficinas);
             })->get();
             return view('contabilidad::Sales.index', compact('salesLogs'));
         } else {
             alert()->error('No tiene permisos para acceder a esta area.', 'Oops!')->persistent('Cerrar');
             return back();
         }
     } else {
         return redirect('login');
     }
 }
Beispiel #23
0
 /**
  * Handle posting of the form for the user registration.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function processRegistration()
 {
     $input = Input::all();
     $rules = ['email' => 'required|email|unique:users', 'password' => 'required', 'password_confirm' => 'required|same:password'];
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     }
     if ($user = Sentinel::register($input)) {
         $activation = Activation::create($user);
         $code = $activation->code;
         $sent = Mail::send('auth.emails.activate', compact('user', 'code'), function ($m) use($user) {
             $m->to($user->email)->subject('Activate Your Account');
         });
         if ($sent === 0) {
             return Redirect::to('register')->withErrors('Failed to send activation email.');
         }
         return Redirect::to('login')->withSuccess('Your accout was successfully created. You might login now.')->with('userId', $user->getUserId());
     }
     return Redirect::to('register')->withInput()->withErrors('Failed to register.');
 }
Beispiel #24
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     setlocale(LC_TIME, 'es_ES');
     $user = Sentinel::getUser();
     $task = Task::find($id);
     $alerts = Alert::where('task_id', '=', $id)->first();
     if (empty($alerts->alert_display)) {
         $array_read[] = $user->id;
         $alerts->alert_display = serialize($array_read);
         $alerts->save();
     } else {
         $array_read = unserialize($alerts->alert_display);
         if (!in_array($user->id, $array_read)) {
             array_push($array_read, $user->id);
             $alerts->alert_display = serialize($array_read);
             $alerts->save();
         }
     }
     return view('notifications.alerts.show', compact('task'));
 }
Beispiel #25
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     /**
      * consulto el rol para actualizar
      */
     $role = Sentinel::findRoleById($id);
     /**
      * Obtengo los valores correspondiente al formulario
      */
     $name = $request->input('name');
     $create = $request->input('user_create');
     $delete = $request->input('user_delete');
     $view = $request->input('user_view');
     $update = $request->input('user_update');
     /**
      * creo el formato correspondiente para los permiso segun lo seleccionado
      */
     /*$permissions="{";
     		$permissions.= $create!=null?'"'.$create.'":true,':'"user.create":false,';
     		$permissions.= $delete!=null?'"'.$delete.'":true,':'"user.delete":false,';
     		$permissions.= $view  !=null?'"'.$view.  '":true,':'"user.view":false,';
     		$permissions.= $update!=null?'"'.$update.'":true' :'"user.update":false';
     		$permissions.="}";*/
     $permissions = array('user.create' => $create != null ? true : false, 'user.delete' => $delete != null ? true : false, 'user.view' => $view != null ? true : false, 'user.update' => $update != null ? true : false);
     try {
         $role->name = $name;
         $role->permissions = $permissions;
         $role->save();
     } catch (QueryException $e) {
         flash()->overlay("Ocurrió un error en el registro, consulte con el administrador <br/>Error:{$e}", 'Aviso');
         return redirect()->back()->withInput($request->all());
     }
     flash()->overlay('Tu registro ha sido modificado!', 'Aviso');
     return redirect("admin/roles");
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     //
     $fields = $request->except('optionsRadios', 'email');
     $fields['icon'] = "fa-envelope-o";
     $user_id = $request->get('user_id');
     $role_id = $request->get('role_id');
     $notification = Notification::find($id);
     if ($request->has('user_id')) {
         $notification->addUser($request->get('user_id'));
     }
     if ($request->has('role_id')) {
         $notification->addRole($request->get('role_id'));
     }
     if ($request->get('email') == 1) {
         if (strcmp($request->get('optionsRadios'), "users") == 0) {
             $user = User::findOrFail($user_id);
             // send email
             $notification->smail($user, $fields);
         } else {
             $role = Sentinel::findRoleById($role_id);
             $users = $role->users()->with('roles')->get();
             //send email
             foreach ($users as $user) {
                 $notification->smail($user, $fields);
             }
         }
     }
     $notification->fill($fields);
     $notification->save();
     flash()->success('La notificación ha sido actualizada.');
     return redirect()->to('notifications');
 }
Beispiel #27
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if (Sentinel::hasAccess('role.delete')) {
         $affectedRows = DB::table('role_users')->where('role_id', '=', $id)->get();
         if (empty($affectedRows)) {
             if ($role = Sentinel::findRoleById($id)) {
                 $role->delete();
             }
             return \Redirect::to('roles')->withErrors('No se pudo eliminar el rol.');
         }
     } else {
         return response()->json(['error' => 'No tiene permisos para acceder a esta area.'], 401);
     }
 }
<?php

require_once "../includes.php";
use Cartalyst\Sentinel\Native\Facades\Sentinel;
Sentinel::getUser();
$start = microtime(true);
if (!Sentinel::check()) {
    $_SESSION["login_redirect"] = "/public_html/verify_columns.php";
    header("location: /public_html/login.php");
    die;
}
$parser = $initializer->columnify($_SESSION["file_path"]);
$columns_info = $parser->find();
$form_options = $parser->form_options;
$original_rows = $parser->original_rows;
$tablehead = "<thead><tr>";
// Creating table header (aka the verification form).
foreach ($columns_info as $name => $data) {
    $options_copy = $form_options;
    $position = $data["position"];
    $yes_checked = $data["checkbox"]["yes_checked?"];
    $no_checked = $data["checkbox"]["no_checked?"];
    $should_hide = $data["checkbox"]["hidden?"];
    $checkbox_text = $data["checkbox"]["text"];
    $category = $data["category"];
    if ($category != "unknown") {
        // Deviding the current category from the rest of the options.
        // The program will display these first.
        $category_options = $options_copy[$category];
        unset($category_options[$name]);
        unset($options_copy[$category]);
Beispiel #29
0
 public function complete($id)
 {
     $user = Sentinel::getUser();
     $task = Task::find($id);
     $now = Carbon::now();
     $task->user_complete_id = $user->id;
     $task->time_complete = $now;
     if ($task->save()) {
         // Ponemos alertas leidas, para que no aparescan cuando ya se completo una tarea
         $alerts = Alert::where('task_id', '=', $id)->first();
         if (empty($alerts->alert_display)) {
             $array_read[] = $user->id;
         } else {
             $array_read = unserialize($alerts->alert_display);
             if (!in_array($user->id, $array_read)) {
                 array_push($array_read, $user->id);
             }
         }
         $alerts->alert_display = serialize($array_read);
         $alerts->save();
         return Redirect::to('tasks/tasks')->withSuccess('Tarea Completada');
     }
 }
 public function __construct(User $model)
 {
     $this->user = $model;
     $this->user_auth = Sentinel::getUser();
 }