From ec2d3b581dd069cec11758b4d2dde19aeb2ee288 Mon Sep 17 00:00:00 2001 From: Malte Schulze Hobeling Date: Tue, 17 Jan 2023 13:47:24 +0100 Subject: [PATCH] fixed salt --- .../bib/essensbestellungsverwaltung/AccountMgr.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/AccountMgr.java b/src/main/java/com/bib/essensbestellungsverwaltung/AccountMgr.java index aa1a856..a6d821f 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/AccountMgr.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/AccountMgr.java @@ -106,9 +106,15 @@ public class AccountMgr { String[] pwH = {"email"}; String[] pwD = {email}; List foundEmail = Database.select("user",pwH,pwD); - String[] userParts = foundEmail.get(0).split(":"); - String[] pwParts = userParts[4].split("\\."); - String salt = pwParts[1]; + String salt; + if(foundEmail.size() == 1){ + String[] userParts = foundEmail.get(0).split(":"); + String[] pwParts = userParts[4].split("\\."); + salt = pwParts[1]; + }else{ + //no unique user found; still calculating a hash for security reasons + salt = getSalt(); + } String[] userH = {"email","password"}; String[] userD = {email,hashAndSalt(pw,salt)}; return Database.getSingleId("user",userH,userD);