/**
  * Reset the given user's password.
  *
  * @param  Request  $request
  * @return Response
  */
 public function postChange(Request $request)
 {
     $validator = Validator::make($request->all(), ['token' => 'required', 'old_passwd' => 'required', 'password' => 'required|confirmed'], [], ['old_passwd' => '原密码', 'password' => '新密码']);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     }
     $auth_array = array('email' => Auth::user()->email, 'password' => Input::get('old_passwd'));
     if (Auth::validate($auth_array)) {
     } else {
         return redirect()->back()->withErrors("请输入正确的密码!");
     }
     $credentials = array('email' => Auth::user()->email, 'password' => Input::get('password'), 'password_confirmation' => Input::get('password_confirmation'), 'token' => Input::get('token'));
     $response = $this->passwords->reset($credentials, function ($user, $password) {
         $user->password = bcrypt($password);
         $user->save();
         $this->auth->login($user);
     });
     switch ($response) {
         case PasswordBroker::PASSWORD_RESET:
             $array = array('email' => Auth::user()->email);
             $token = $this->passwords->getToken($array);
             UserManageLog::insertLog("修改密码", Auth::user()->id, Auth::user()->name, Auth::user()->email, Auth::user()->name . '(' . Auth::user()->email . ')', null, null, $request->ip());
             return view('auth.change_password')->withTips("密码修改成功!")->withToken($token);
         default:
             return redirect()->back()->withErrors(['email' => trans($response)]);
     }
 }
コード例 #2
0
 public function getDestroy(Request $request, $id)
 {
     $user = User::find($id);
     $operated = $user->name . '(' . $user->email . ')';
     if ($user->role == "root") {
         return Redirect::back()->withInput()->withErrors(['删除失败!非法操作!']);
     }
     $before = $user->toJson();
     if ($user->delete()) {
         UserManageLog::insertLog('删除用户', Auth::user()->id, Auth::user()->name, Auth::user()->email, $operated, $before, null, $request->ip());
         return Redirect::back();
     } else {
         return Redirect::back()->withErrors(['删除失败!']);
     }
 }
コード例 #3
0
 public function getUsermanagelog()
 {
     $pages = UserManageLog::orderBy('created_at', 'desc')->paginate(15);
     return view('log.usermanagelog')->withPages($pages);
 }