From 56782a80d006507b2d6e29ea043571c6e3568410 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Sat, 30 Apr 2022 12:29:03 +0200 Subject: [PATCH] fixed case-sensitivity of user email --- pom.xml | 2 +- .../java/de/srsoftware/widerhall/data/MailingList.java | 3 ++- src/main/java/de/srsoftware/widerhall/data/User.java | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index e500570..1a45dd5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.example Widerhall - 0.2.52 + 0.2.53 diff --git a/src/main/java/de/srsoftware/widerhall/data/MailingList.java b/src/main/java/de/srsoftware/widerhall/data/MailingList.java index 6c2d98c..46f82da 100644 --- a/src/main/java/de/srsoftware/widerhall/data/MailingList.java +++ b/src/main/java/de/srsoftware/widerhall/data/MailingList.java @@ -84,7 +84,7 @@ public class MailingList implements MessageHandler, ProblemListener { * @param state */ public MailingList(String email, String name, String imapHost, int imapPort, String imapUser, String imapPass, String inbox, String smtpHost, int smtpPort, String smtpUser, String smtpPass, int state) { - this.email = email; + this.email = email.toLowerCase(); this.name = name; this.state = state; this.smtp = new SmtpClient(smtpHost,smtpPort,smtpUser,smtpPass,email); @@ -259,6 +259,7 @@ public class MailingList implements MessageHandler, ProblemListener { */ public static MailingList load(String listEmail) { if (listEmail == null) return null; + listEmail = listEmail.toLowerCase(); var ml = cache.get(listEmail); try { var rs = Database.open() diff --git a/src/main/java/de/srsoftware/widerhall/data/User.java b/src/main/java/de/srsoftware/widerhall/data/User.java index 7473bc1..d2321d4 100644 --- a/src/main/java/de/srsoftware/widerhall/data/User.java +++ b/src/main/java/de/srsoftware/widerhall/data/User.java @@ -34,7 +34,7 @@ public class User { * @param permissions */ public User(String email, String name, String salt, String hashedPass, int permissions) { - this.email = email; + this.email = email.toLowerCase(); this.name = name; this.salt = salt; this.hashedPass = hashedPass; @@ -91,6 +91,7 @@ public class User { * @throws SQLException */ public static User create(String email, String name, String password) throws SQLException { + email = email.toLowerCase(); String salt = null; String hashedPass = null; if (password != null) { @@ -139,7 +140,7 @@ public class User { } public static User load(String email) throws SQLException { - var rs = Database.open().select(TABLE_NAME).where(EMAIL,email).compile().exec(); + var rs = Database.open().select(TABLE_NAME).where(EMAIL,email.toLowerCase()).compile().exec(); try { if (rs.next()) { return User.from(rs); @@ -208,7 +209,7 @@ public class User { public static User loadUser(String email, String password) throws InvalidKeyException, SQLException { ResultSet rs = Database.open() .select(TABLE_NAME) - .where(EMAIL,email) + .where(EMAIL,email.toLowerCase()) .compile() .exec(); try {