<?php

class SendPasswordRemindMailAction  extends SOY2Action{

	protected function execute(SOY2ActionRequest &$request,SOY2ActionForm &$form,SOY2ActionResponse &$response){
		
		$email = $request->getParameter("email");
		
		$dao = SOY2DAOFactory::create("asp.ASPUserDAO");
		
		try{
			$user = $dao->getByEmail($email);
			
			$crypt = crypt($user->getEmail());
			$newPassword = base64_encode(substr($crypt,strlen($crypt)-12));
			
			$user->setPassword(crypt($newPassword,$user->getEmail()));
			$dao->update($user);
			
			$mailLogic = SOY2Logic::createInstance("logic.asp.ASPMailLogic");
			$mailLogic->sendPasswordMail($user,$newPassword);
		}catch(Exception $e){
			return SOY2Action::FAILED;
		}
		return SOY2Action::SUCCESS;
	}
}
?>