package com.gtp.controller;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.mail.MessagingException;
import com.gtp.domain.User;
import com.gtp.service.ReminderService;
import commons.NotFoundException;
public class ReminderController {
String email,secretQuestion,secretAnswer;
ReminderService reminderService;
public String remind(){
User user=new User();
user.setEmail(email);
user.setSecretQuestion(secretQuestion);
user.setSecretAnswer(secretAnswer);
try {
try {
reminderService.remindPassword(user);
} catch (MessagingException e) {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Mail was not sent",""));
e.printStackTrace();
return null;
}
} catch (NotFoundException e) {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_WARN,
"wrong email adress",""));
e.printStackTrace();
return null;
}
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO,
"", "Successful"));
return null;
}
public ReminderService getReminderService() {
return reminderService;
}
public void setReminderService(ReminderService reminderService) {
this.reminderService = reminderService;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSecretAnswer() {
return secretAnswer;
}
public void setSecretAnswer(String secretAnswer) {
this.secretAnswer = secretAnswer;
}
public String getSecretQuestion() {
return secretQuestion;
}
public void setSecretQuestion(String secretQuestion) {
this.secretQuestion = secretQuestion;
}
}