Esempio n. 1
0
 /**
  * Saving new password.
  *
  * @param  \Orchestra\Model\User $user
  * @param  array  $input
  */
 protected function saving(Eloquent $user, array $input)
 {
     $user->setAttribute('password', $input['new_password']);
     DB::transaction(function () use($user) {
         $user->save();
     });
 }
Esempio n. 2
0
 /**
  * Handle `orchestra.saved: user.account` event.
  *
  * @param  \Orchestra\Model\User  $user
  *
  * @return void
  */
 public function handle($user)
 {
     if (!$this->isLocaltimeEnabled()) {
         return;
     }
     $userId = $user->getAttribute('id');
     $meta = $this->memory->make('user');
     $meta->put("timezone.{$userId}", Input::get('meta_timezone'));
 }
Esempio n. 3
0
 /**
  * Save user profile.
  *
  * @param  \Orchestra\Model\User|\Illuminate\Database\Eloquent\Model  $user
  * @param  array  $input
  *
  * @return void
  */
 protected function saving($user, array $input)
 {
     $user->setAttribute('email', $input['email']);
     $user->setAttribute('fullname', $input['fullname']);
     $this->fireEvent('updating', [$user]);
     $this->fireEvent('saving', [$user]);
     $user->saveOrFail();
     $this->fireEvent('updated', [$user]);
     $this->fireEvent('saved', [$user]);
 }
Esempio n. 4
0
 /**
  * Save the user.
  *
  * @param  \Orchestra\Model\User  $user
  * @param  array  $input
  * @param  string  $type
  *
  * @return bool
  */
 protected function saving(Eloquent $user, $input = [], $type = 'create')
 {
     $beforeEvent = $type === 'create' ? 'creating' : 'updating';
     $afterEvent = $type === 'create' ? 'created' : 'updated';
     $user->fullname = $input['fullname'];
     $user->email = $input['email'];
     $this->fireEvent($beforeEvent, [$user]);
     $this->fireEvent('saving', [$user]);
     DB::transaction(function () use($user, $input) {
         $user->save();
         $user->roles()->sync($input['roles']);
     });
     $this->fireEvent($afterEvent, [$user]);
     $this->fireEvent('saved', [$user]);
     return true;
 }
Esempio n. 5
0
 /**
  * Validate current user.
  *
  * @param  \Orchestra\Model\User|\Illuminate\Database\Eloquent\Model  $user
  * @param  array  $input
  *
  * @return bool
  */
 protected function validateCurrentUser($user, array $input)
 {
     return (string) $user->getAttribute('id') === $input['id'];
 }
Esempio n. 6
0
 /**
  * Verify user account if has not been verified, other this should
  * be ignored in most cases.
  *
  * @param  \Orchestra\Model\User  $user
  *
  * @return \Orchestra\Model\User
  */
 protected function verifyWhenFirstTimeLogin(Eloquent $user)
 {
     if ((int) $user->getAttribute('status') === Eloquent::UNVERIFIED) {
         $user->activate()->save();
     }
     return $user;
 }
Esempio n. 7
0
 /**
  * Saving new user.
  *
  * @param  \Orchestra\Model\User  $user
  * @param  array  $input
  * @param  string  $password
  *
  * @return void
  */
 protected function saving(Eloquent $user, array $input, $password)
 {
     $user->setAttribute('email', $input['email']);
     $user->setAttribute('fullname', $input['fullname']);
     $user->setAttribute('password', $password);
     $this->fireEvent('creating', [$user]);
     $this->fireEvent('saving', [$user]);
     DB::transaction(function () use($user) {
         $user->save();
         $user->roles()->sync([Config::get('orchestra/foundation::roles.member', 2)]);
     });
     $this->fireEvent('created', [$user]);
     $this->fireEvent('saved', [$user]);
 }
Esempio n. 8
0
 /**
  * Saving new password.
  *
  * @param  \Orchestra\Model\User $user
  * @param  array  $input
  */
 protected function saving(Eloquent $user, array $input)
 {
     $user->setAttribute('password', $input['new_password']);
     $user->saveOrFail();
 }