public function forgotPassword()
 {
     $response = Password::remind(Input::only('email'), function ($message) {
         $message->subject('Password Reminder');
     });
     switch ($response) {
         case Password::REMINDER_SENT:
             $success = true;
             $message = 'Please check your email for a reset link';
             break;
         case Password::INVALID_USER:
             $success = false;
             $message = 'No account found matching this email';
             break;
     }
     return Response::json(['success' => $success, 'message' => $message]);
 }
コード例 #2
0
ファイル: UserController.php プロジェクト: ioangogo/gruik
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $userRepo = \App::make('Gruik\\Repo\\User\\UserInterface');
     $user = $userRepo->byId($id);
     if ($user && $user->id == \Sentry::getUser()->id) {
         $inputs = Input::all();
         // Password change
         $new_password = array_pull($inputs, 'new_password', false);
         $new_password_conf = array_pull($inputs, 'new_password_conf', false);
         $email = array_pull($inputs, 'email', false);
         if ($new_password || $new_password_conf) {
             if ($new_password == $new_password_conf) {
                 $user->password = $new_password;
             } else {
                 return \Response::json(['flash' => 'Passwords must be the same !'], 400);
             }
         }
         // Email change
         if ($email != $user->email) {
             if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
                 $user->email = $email;
             } else {
                 return \Response::json(['flash' => 'Email address is not valid !'], 400);
             }
         }
         // Preferences
         $preferences = array_pull($inputs, 'preferences', false);
         $userRepo->setPreferencesForUser($id, $preferences);
         $user = $user->fill($inputs);
         $user->save();
         return \Response::json($user, 200);
     } else {
         return \Response::json("Unauthorized : User doesn't exist OR you can't modify it", 400);
     }
 }
コード例 #3
0
ファイル: PostController.php プロジェクト: ioangogo/gruik
 public function search()
 {
     $term = Input::get('term', false);
     $tags = Input::get('tags', false);
     $postRepo = \App::make('Gruik\\Repo\\Post\\PostInterface');
     $posts = [];
     if ($term) {
         $term = trim($term);
         $posts = $postRepo->searchByTerm($term, \Sentry::getUser()->id);
     }
     if ($tags) {
     }
     return \Response::json($posts, 200);
 }