Commit 446dcaf1 authored by Matija Obreza's avatar Matija Obreza

User profile controller uses updated token verification service

parent 963058fb
...@@ -70,7 +70,7 @@ public class TokenVerificationServiceImpl implements TokenVerificationService { ...@@ -70,7 +70,7 @@ public class TokenVerificationServiceImpl implements TokenVerificationService {
} }
if (!verificationToken.getKey().equals(key)) { if (!verificationToken.getKey().equals(key)) {
LOG.error("Email verification key invalid for token=" + verificationToken.getUuid() + " providedKey=" + key); LOG.error("Verification key invalid for token=" + verificationToken.getUuid() + " providedKey=" + key);
throw new NoSuchVerificationTokenException(); throw new NoSuchVerificationTokenException();
} }
......
...@@ -24,6 +24,7 @@ import org.genesys2.server.model.impl.User; ...@@ -24,6 +24,7 @@ import org.genesys2.server.model.impl.User;
import org.genesys2.server.service.ContentService; import org.genesys2.server.service.ContentService;
import org.genesys2.server.service.EMailVerificationService; import org.genesys2.server.service.EMailVerificationService;
import org.genesys2.server.service.TeamService; import org.genesys2.server.service.TeamService;
import org.genesys2.server.service.TokenVerificationService.NoSuchVerificationTokenException;
import org.genesys2.server.service.UserService; import org.genesys2.server.service.UserService;
import org.genesys2.spring.ResourceNotFoundException; import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -135,10 +136,10 @@ public class UserProfileController extends BaseController { ...@@ -135,10 +136,10 @@ public class UserProfileController extends BaseController {
@RequestMapping(value = "/{tokenUuid:.+}/validate", method = RequestMethod.POST) @RequestMapping(value = "/{tokenUuid:.+}/validate", method = RequestMethod.POST)
public String validateEmail2(ModelMap model, @PathVariable("tokenUuid") String tokenUuid, @RequestParam(value = "key", required = true) String key) { public String validateEmail2(ModelMap model, @PathVariable("tokenUuid") String tokenUuid, @RequestParam(value = "key", required = true) String key) {
try {
if (emailVerificationService.validateEMail(tokenUuid, key)) { emailVerificationService.validateEMail(tokenUuid, key);
return "redirect:/profile"; return "redirect:/profile";
} else { } catch (NoSuchVerificationTokenException e) {
// Not valid // Not valid
model.addAttribute("tokenUuid", tokenUuid); model.addAttribute("tokenUuid", tokenUuid);
model.addAttribute("error", "error"); model.addAttribute("error", "error");
...@@ -167,9 +168,10 @@ public class UserProfileController extends BaseController { ...@@ -167,9 +168,10 @@ public class UserProfileController extends BaseController {
public String updatePassword(ModelMap model, @PathVariable("tokenUuid") String tokenUuid, @RequestParam(value = "key", required = true) String key, public String updatePassword(ModelMap model, @PathVariable("tokenUuid") String tokenUuid, @RequestParam(value = "key", required = true) String key,
@RequestParam("password") String password) throws UserException { @RequestParam("password") String password) throws UserException {
if (emailVerificationService.changePassword(tokenUuid, key, password)) { try {
emailVerificationService.changePassword(tokenUuid, key, password);
return "redirect:/content/user.password-reset"; return "redirect:/content/user.password-reset";
} else { } catch (NoSuchVerificationTokenException e) {
// Not valid // Not valid
model.addAttribute("tokenUuid", tokenUuid); model.addAttribute("tokenUuid", tokenUuid);
model.addAttribute("error", "error"); model.addAttribute("error", "error");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment