Exemplo n.º 1
0
 public function setUp()
 {
     parent::setUp();
     $databaseUrl = __DIR__ . '/../tests/studs/testing.sqlite';
     $runMigrate = false;
     $fileSystem = new \Illuminate\Filesystem\Filesystem();
     if (!$this->inMemoryDb && !$fileSystem->exists($databaseUrl)) {
         $fileSystem->put($databaseUrl, '');
         $runMigrate = true;
         fwrite(STDOUT, "\r\n- Migrate \r\n");
     }
     $this->app['config']->set('app.key', 'SomeRandomStringWith32Characters');
     $this->app['config']->set('app.debug', true);
     $this->app['config']->set('database.default', 'sqlite');
     $this->app['config']->set('database.connections.sqlite.database', $this->inMemoryDb ? ':memory:' : $databaseUrl);
     if ($runMigrate || $this->inMemoryDb) {
         $this->migrate();
         $this->createSiteAndAdminUser();
     }
     // generally it is not run during console calls, but it is ok for testing, because
     // system knows that site's url is localhost
     app('veer')->run();
     $admin = \Veer\Models\UserAdmin::where('banned', 0)->first();
     \Auth::loginUsingId($admin->users_id);
 }
Exemplo n.º 2
0
 /**
  * @todo use ranks to determine who can update whom
  * @param array $data
  * @return \Veer\Services\Administration\Elements\User
  */
 public function updateOneAdministrator($data)
 {
     if (!empty($data) && is_array($data)) {
         $data['banned'] = !empty($data['banned']) ? true : false;
         if ($this->id == \Auth::id()) {
             // one cannot ban himself
             unset($data['banned']);
         }
         \Veer\Models\UserAdmin::where('users_id', '=', $this->id)->update($data);
     }
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Login Post
  */
 public function loginPost()
 {
     $save_old_session_id = \Session::getId();
     if (\Auth::attempt(array('email' => \Input::get('email'), 'password' => \Input::get('password'), 'banned' => 0, 'sites_id' => app('veer')->siteId))) {
         \Auth::user()->increment('logons_count');
         \Session::put('roles_id', \Auth::user()->roles_id);
         \Veer\Models\UserList::where('session_id', '=', $save_old_session_id)->update(array('users_id' => \Auth::id()));
         \Session::put('shopping_cart_items', $this->showUser->getUserLists(app('veer')->siteId, \Auth::id(), app('session')->getId()));
         if (administrator() == true) {
             \Veer\Models\UserAdmin::where('id', '=', app('veer')->administrator_credentials['id'])->update(array("sess_id" => \Session::getId(), "last_logon" => now(), "ips" => \Illuminate\Support\Facades\Request::getClientIp(), "logons_count" => app('veer')->administrator_credentials['logons_count'] + 1));
         }
         return \Redirect::intended();
     }
     return $this->login();
     // @todo withErrors()
 }