Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function changePasswordAction(){
- $validate = 0;
- $result = '';
- $customer = Mage::getSingleton ( 'customer/session' );
- if ($customer->isLoggedIn()):
- echo $customerid = $customer->getCustomer()->getId();
- echo $oldpassword = $this->getRequest()->getParam('oldpassword');
- echo $newpassword = $this->getRequest()->getParam('newpassword');
- $username = $customer->getCustomer()->getEmail();
- $websiteId = Mage::getModel('core/store')->load($this->storeId)->getWebsiteId();
- try {
- $login_customer_result = Mage::getModel('customer/customer')->setWebsiteId('1')->authenticate($username, $oldpassword);
- $validate = 1;
- }
- catch(Exception $ex) {
- $validate = 0;
- }
- if($validate == 1) {
- try {
- $customer = Mage::getModel('customer/customer')->load($customerid);
- $customer->setPassword($newpassword);
- $customer->save();
- echo json_encode(array('status'=>'success','message'=>'Your Password has been Changed Successfully'));
- exit;
- }
- catch(Exception $ex) {
- echo json_encode(array('status'=>'error','message'=>'Error : '.$ex->getMessage()));
- exit;
- }
- }
- else {
- echo json_encode(array('status'=>'error','message'=>'Incorrect Old Password.'));
- exit;
- }
- else:
- echo json_encode(array('status'=>'error','message'=>'Kindly Signin first.'));
- exit;
- endif;
- }
Add Comment
Please, Sign In to add comment