예제 #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);
 }
예제 #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();
     });
 }
예제 #3
0
파일: User.php 프로젝트: exelv1/Contentify
 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');
         }
     });
 }
예제 #4
0
파일: User.php 프로젝트: TimLeytens/User
 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);
 }
예제 #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']);
                 }
             }
         }
     }
 }
예제 #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);
 }
예제 #7
0
 public function testSettingLoginAttribute()
 {
     $originalAttribute = User::getLoginAttribute();
     User::setLoginAttribute('foo');
     $this->assertEquals('foo', User::getLoginAttribute());
     user::setLoginAttribute($originalAttribute);
 }
예제 #8
0
파일: User.php 프로젝트: subbly/framework
 /**
  *
  */
 protected function performInsert(\Illuminate\Database\Eloquent\Builder $query, array $options = array())
 {
     $this->attributes['uid'] = md5(uniqid(mt_rand(), true));
     parent::performInsert($query, $options);
 }
예제 #9
0
파일: User.php 프로젝트: xhulioh25/wiki
 /**
  * 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();
 }
예제 #11
0
파일: User.php 프로젝트: srit83/extsentry
 public function recordLogin()
 {
     $oLogin = new Login();
     $this->logins()->save($oLogin);
     return parent::recordLogin();
 }
예제 #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;
 }
예제 #13
0
파일: User.php 프로젝트: chirilo/Contentify
 /**
  * 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'));
 }
예제 #14
0
파일: User.php 프로젝트: ymnl007/92five
 /**
  * Indicates if the model should soft delete.
  *
  * @var bool
  */
 public function __construct()
 {
     parent::__construct();
 }
예제 #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;
 }
예제 #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'));
 }
예제 #17
0
파일: User.php 프로젝트: arturishe21/buider
 public static function boot()
 {
     parent::boot();
 }