Example #1
0
 /**
  * Updates an existent user
  *
  * @param $user
  * @param array $input
  * @return bool
  */
 public function update($user, array $input)
 {
     if (!$this->valid($input, 'updating')) {
         return false;
     }
     return $this->user->update($user, $input);
 }
Example #2
0
 /**
  * Create a new user
  *
  * @return boolean
  */
 public function create(array $input)
 {
     if (!$this->valid($input)) {
         return false;
     }
     return $this->user->create($input);
 }
 /**
  * Activate account
  * GET /auth/activate/{slug}/key/{activation_key}
  */
 public function getActivateAccount($userSlug, $activationKey)
 {
     $user = $this->user->bySlug($userSlug);
     if ($user->isActive()) {
         return Redirect::route('home')->with('message', 'This user account is already active.');
     }
     if ($user->activate($activationKey)) {
         Auth::login($user);
         return Redirect::route('home')->with('message', 'Your account is now activated.')->with('messageType', "success");
     } else {
         return Redirect::route('home')->with('message', 'Invalid activation key.');
     }
 }
 public function update($slug, array $input)
 {
     $snippet = $this->snippet->bySlug($slug, $all = true);
     if (!$snippet->isTheAuthor(Auth::user())) {
         return App::abort(404);
     }
     if (!$this->valid($input)) {
         return false;
     }
     // validate if tags chosen are valid
     // @TODO: move this into a helper so we can re-use this one
     $tagIds = $this->tag->all()->lists('id');
     if (isset($input['tags']) && count($input['tags']) > 0) {
         foreach ($input['tags'] as $id) {
             if (!in_array($id, $tagIds)) {
                 return App::abort(404);
             }
         }
     }
     if (!$this->snippet->update($snippet, $input)) {
         return false;
     }
     return $snippet;
 }