Ejemplo n.º 1
0
 public static function __callStatic($method, $parameters)
 {
     $sentryUserProvider = Sentry::getUserProvider();
     if (method_exists($sentryUserProvider, $method)) {
         return call_user_func_array(array($sentryUserProvider, $method), $parameters);
     }
     return parent::__callStatic($method, $parameters);
 }
Ejemplo n.º 2
0
 public static function boot()
 {
     parent::boot();
     //删除时先删除相关文档、单页
     self::deleting(function (User $user) {
         Article::where('uid', '=', $user->id)->delete();
         Page::where('uid', '=', $user->id)->delete();
     });
 }
Ejemplo n.º 3
0
 public static function boot()
 {
     parent::boot();
     self::updated(function ($user) {
         /*
          * Update the locale (since its stored in a session variable we need to update it)
          * when changed in profile or use just logged in.
          */
         if (user() and user()->id == $user->id) {
             Session::forget('locale');
         }
     });
 }
Ejemplo n.º 4
0
 public function __call($method, $parameters)
 {
     $class_name = class_basename($this);
     #i: Convert array to dot notation
     $config = implode('.', ['relations', $class_name, $method]);
     #i: Relation method resolver
     if (Config::has($config)) {
         $function = Config::get($config);
         return $function($this);
     }
     #i: No relation found, return the call to parent (Eloquent) to handle it.
     return parent::__call($method, $parameters);
 }
Ejemplo n.º 5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $create = $this->option('create');
     $delete = $this->option('delete');
     if (!empty($create)) {
         $name = $this->ask('Enter the name of the user:'******'Enter the name of the user:'******'Enter the password for the user:'******'Make sure the password is longer than 5 characters');
             $password = $this->secret('Enter the password for the user:'******'Re-enter the password to confirm:');
         while ($pwConfirm != $password) {
             $pwConfirm = $this->secret('The passwords did not match, re-enter the password to confirm:');
         }
         // Create 'everyone' user and group
         Sentry::getUserProvider()->create(array('email' => $name, 'password' => $pwConfirm, 'first_name' => $name, 'last_name' => '', 'activated' => 1));
         $newUser = Sentry::getUserProvider()->findByLogin($name);
         $adminGroup = Sentry::getGroupProvider()->findByName('superadmin');
         $newUser->addGroup($adminGroup);
         $this->info('The user ' . $name . ' has been created and activated.');
     } else {
         if (!empty($delete)) {
             $name = $this->ask('Enter the name of the user you want to delete.');
             while (empty($name)) {
                 $name = $this->ask('Enter the name of the user you want to delete.');
             }
             $user = User::where(['email' => $name])->first();
             if (empty($user)) {
                 $this->error('No user with the name ' . $name . ' has been found.');
             } else {
                 if ($this->confirm('The user ' . $name . ' has been found, are you sure you want do delete? [yes|no]')) {
                     $user->delete();
                 } else {
                     $this->info('The user ' . $name . ' has not been removed.');
                 }
             }
         } else {
             // Get all of the users
             $users = User::all(['email'])->toArray();
             foreach ($users as $user) {
                 if ($user['email'] != 'everyone') {
                     $this->info($user['email']);
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * Create a new Eloquent model instance.
  *
  * @param  array  $attributes
  * @return void
  */
 public function __construct(array $attributes = array())
 {
     $this->{$this->getKeyName()} = (string) $this->generateNewId();
     parent::__construct($attributes);
 }
Ejemplo n.º 7
0
 public function testSettingLoginAttribute()
 {
     $originalAttribute = User::getLoginAttribute();
     User::setLoginAttribute('foo');
     $this->assertEquals('foo', User::getLoginAttribute());
     user::setLoginAttribute($originalAttribute);
 }
Ejemplo n.º 8
0
 /**
  *
  */
 protected function performInsert(\Illuminate\Database\Eloquent\Builder $query, array $options = array())
 {
     $this->attributes['uid'] = md5(uniqid(mt_rand(), true));
     parent::performInsert($query, $options);
 }
Ejemplo n.º 9
0
 /**
  * Removes the user from the given group.
  *
  * @param \Cartalyst\Sentry\Groups\GroupInterface $group
  *
  * @return bool
  */
 public function removeGroup(GroupInterface $group)
 {
     RevisionRepository::create(['revisionable_type' => get_class($this), 'revisionable_id' => $this->getKey(), 'key' => 'removed_group', 'old_value' => null, 'new_value' => $group->getName(), 'user_id' => Credentials::getUser()->id]);
     return parent::removeGroup($group);
 }
 /**
  * Close mockery.
  *
  * @return void
  */
 public function tearDown()
 {
     m::close();
     User::unsetHasher();
 }
Ejemplo n.º 11
0
 public function recordLogin()
 {
     $oLogin = new Login();
     $this->logins()->save($oLogin);
     return parent::recordLogin();
 }
Ejemplo n.º 12
0
 /**
  * Adds the array of groups to the specified user.
  *
  * @param \Cartalyst\Sentry\Users\Eloquent\User $user
  * @param array                                 $groups
  *
  * @return bool
  */
 private function addGroupsToUser($user, array $groups = [])
 {
     if (count($groups) > 0) {
         foreach ($groups as $group) {
             try {
                 $group = Sentry::findGroupByName($group);
                 $user->addGroup($group);
             } catch (GroupNotFoundException $e) {
             }
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 13
0
 /**
  * Get the attributes that should be converted to dates.
  *
  * @return array
  */
 public function getDates()
 {
     return array_merge(parent::getDates(), array('activated_at', 'last_login', 'last_active'));
 }
Ejemplo n.º 14
0
 /**
  * Indicates if the model should soft delete.
  *
  * @var bool
  */
 public function __construct()
 {
     parent::__construct();
 }
Ejemplo n.º 15
0
 /**
  * Function to override default implementation of getMergedPermissions.
  * 
  * Here we try to merge morePermissions variable into the 
  *
  * @return void
  * @author 
  **/
 public function getMergedPermissions()
 {
     $result = parent::getMergedPermissions();
     $result = array_merge($result, $this->getMorePermissions());
     return $result;
 }
Ejemplo n.º 16
0
 /**
  * Set the Sentry User Model Hasher to be the same as the configured Sentry Hasher
  */
 public static function boot()
 {
     parent::boot();
     static::setHasher(app()->make('sentry.hasher'));
 }
Ejemplo n.º 17
0
 public static function boot()
 {
     parent::boot();
 }