@@ -0,0 +1,1933 @@
+package com.pollistics.controllers;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.validation.Valid;%0A%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.stereotype.Controller;%0Aimport org.springframework.ui.Model;%0Aimport org.springframework.validation.BindingResult;%0Aimport org.springframework.validation.FieldError;%0Aimport org.springframework.web.bind.annotation.GetMapping;%0Aimport org.springframework.web.bind.annotation.ModelAttribute;%0Aimport org.springframework.web.bind.annotation.PostMapping;%0A%0Aimport com.pollistics.models.User;%0Aimport com.pollistics.models.validators.UserValidator;%0Aimport com.pollistics.services.UserService;%0A%0A@Controller%0Apublic class AccountController %7B%0A%09@Autowired%0A%09private UserService userService;%0A%09%0A%09@GetMapping(value = %22/account%22)%0A%09public String account(Model model) %7B%0A%09%09return %22account/index%22;%0A%09%7D%0A%09%0A%09@GetMapping(value = %22/login%22)%0A%09public String login(HttpServletRequest request, Model model) %7B%0A%09%09model.addAttribute(%22request%22, request);%0A%09%09return %22account/login%22;%0A%09%7D%0A%09%0A%09@GetMapping(value = %22/register%22)%0A%09public String register(Model model) %7B%0A%09%09return %22account/register%22;%0A%09%7D%0A%09%0A%09@PostMapping(value = %22/register%22)%0A%09public String postRegister(HttpServletRequest request, @Valid @ModelAttribute(%22user%22) User user, BindingResult result, Model model) %7B%0A%09%09if(!request.getParameter(%22password1%22).equals(request.getParameter(%22password%22))) %7B%0A%09%09%09result.addError(new FieldError(%22user%22, %22password1%22, %22Passwords don't match%22));%0A%09%09%7D%0A%09%09if(userService.userExists(user.getUsername())) %7B%0A%09%09%09result.addError(new FieldError(%22user%22, %22username%22, %22Username is already taken%22));%0A%09%09%7D%0A%09%09%0A%09%09UserValidator userValidator = new UserValidator();%0A        userValidator.validate(user, result);%0A%09%09%0A%09%09if (result.hasErrors())%7B%0A%09%09%09model.addAttribute(%22errors%22, result);%0A%09%09%09return %22account/register%22;%0A%09    %7D%0A%09    else %7B%0A%09    %09userService.createUser(user);%0A%09    %09return %22redirect:/%22;%0A%09    %7D%0A%09%7D%0A%7D%0A

add Account controller