public function profile() { $userInfo = Auth::user(); if (Request::isMethod('post')) { $id = Auth::user()->id; if (User::checkUserPassword($id, Input::get('password')) == true) { $msgType = 'error'; $message = 'Password has been used before. <br /> Change your password at least 5 times before using this password again.'; return Redirect::action('user.profile')->with($msgType, $message); } $user = User::where('id', $id)->find($id); $user->password = Hash::make(Input::get('password')); $user->last_password_change = new DateTime(); $settingsExpiry = Settings::getSettingValue('password_expiry'); $user->password_expiration_date = User::userPasswordExpiry(date("Y-m-d H:i:s"), $settingsExpiry); $passwords = json_decode($user->passwords, true); if (sizeof($passwords) == 0) { $temp = array(); $temp[] = Hash::make(Input::get('password')); $user->passwords = json_encode($temp); } else { array_push($passwords, Hash::make(Input::get('password'))); if (sizeof($passwords) > 5) { array_shift($passwords); } $user->passwords = json_encode($passwords); } if ($user->save()) { $msgType = 'success'; $message = 'Password has been changed'; } else { $msgType = 'error'; $message = 'Password has been failed'; } return Redirect::action('user.profile')->with($msgType, $message); } else { $title = Lang::get('My Profile'); return View::make('user/profile', array('userInfo' => $userInfo, 'title' => $title)); } }