Skip to content
Snippets Groups Projects
Commit 8e94d922 authored by Joshua Gill's avatar Joshua Gill
Browse files

All instances of an email now being set to lowercase, database NOT updated

parent 3560c9c8
No related branches found
No related tags found
1 merge request!114LoggingService service class, new method to add a log to the "Logs" table when...
......@@ -23,10 +23,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.*;
@Controller
public class SignInController {
......@@ -127,7 +124,7 @@ public class SignInController {
return "account-login.html";
}
Optional<UsersDTO> usersDTOOptional = usersSearch.findByEmail(loginForm.getLoginEmail());
Optional<UsersDTO> usersDTOOptional = usersSearch.findByEmail(loginForm.getLoginEmail().toLowerCase());
// If the optional is present - the search found a user with that email
if (usersDTOOptional.isPresent()) {
// Check the password given (after encoding) and the user's DB password match
......
......@@ -71,7 +71,7 @@ public class SignUpController {
Users newUser = new Users(
signUpForm.getNewUserForename(),
signUpForm.getNewUserLastname(),
signUpForm.getNewUserEmail(),
signUpForm.getNewUserEmail().toLowerCase(),
passwordEncoder.encode(signUpForm.getNewUserPassword()),
signUpForm.getUserProfilePicture(),
new TwoFactorMethods(1, "None")
......@@ -80,7 +80,7 @@ public class SignUpController {
// Save the new user
usersRepo.save(newUser);
// Get the user
usersDTOOptional = usersSearch.findByEmail(signUpForm.getNewUserEmail());
usersDTOOptional = usersSearch.findByEmail(signUpForm.getNewUserEmail().toLowerCase());
// Create a JWTSession
jwtUtils.makeUserJWT(
(int) usersDTOOptional.get().getUserId(),
......
......@@ -84,7 +84,7 @@ public class UserSettingsController {
miscQueries.updateUser(
userId,
"User_Email",
nameEmailProfileChangeForm.getNewEmail()
nameEmailProfileChangeForm.getNewEmail().toLowerCase()
);
}
......
......@@ -24,7 +24,7 @@ public class EmailValidator {
@GetMapping("/emailInUse")
public boolean emailInUse(@RequestParam(value = "email") String email) throws Exception{
Optional<UsersDTO> users = usersSearch.findByEmail(email);
Optional<UsersDTO> users = usersSearch.findByEmail(email.toLowerCase());
return users.isPresent();
}
}
......@@ -70,7 +70,7 @@ public class UserSettings {
miscQueries.updateUser(
userId,
"User_Email",
nameEmailProfileChangeForm.getNewEmail()
nameEmailProfileChangeForm.getNewEmail().toLowerCase()
);
}
......
......@@ -35,7 +35,7 @@ public class loginAPI {
throw new ForbiddenErrorException("Details Incorrect");
}
Optional<UsersDTO> usersDTOOptional = usersSearch.findByEmail(loginForm.getLoginEmail());
Optional<UsersDTO> usersDTOOptional = usersSearch.findByEmail(loginForm.getLoginEmail().toLowerCase());
// If the optional is present - the search found a user with that email
if (usersDTOOptional.isPresent()) {
// Check the password given (after encoding) and the user's DB password match
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment