From fcff0a0a83a1951180843044f32f8db94cba107c Mon Sep 17 00:00:00 2001 From: jcschaff Date: Tue, 9 Jul 2024 18:02:50 -0400 Subject: [PATCH] fix NullPointerException if userid not found for recover account --- .../java/org/vcell/restq/db/SMTPService.java | 45 ------------------- .../java/org/vcell/restq/db/UserRestDB.java | 3 ++ 2 files changed, 3 insertions(+), 45 deletions(-) delete mode 100644 vcell-rest/src/main/java/org/vcell/restq/db/SMTPService.java diff --git a/vcell-rest/src/main/java/org/vcell/restq/db/SMTPService.java b/vcell-rest/src/main/java/org/vcell/restq/db/SMTPService.java deleted file mode 100644 index c86edcb158..0000000000 --- a/vcell-rest/src/main/java/org/vcell/restq/db/SMTPService.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.vcell.restq.db; - -import jakarta.enterprise.context.ApplicationScoped; -import org.eclipse.microprofile.config.inject.ConfigProperty; - -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.AddressException; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; - -@ApplicationScoped -public class SMTPService { - - @ConfigProperty(name = "vcell.smtp.hostName") - String smtpHostName; - - @ConfigProperty(name = "vcell.smtp.port") - String smtpPost; - - @ConfigProperty(name = "vcell.smtp.emailAddress") - String smtpEmail; - - - public void sendEmail(String emailAddress, String subject, String body) throws MessagingException { - // Create a mail session - java.util.Properties props = new java.util.Properties(); - props.put("mail.smtp.host", smtpHostName); - props.put("mail.smtp.port", "" + Integer.parseInt(smtpPost)); - Session session = Session.getDefaultInstance(props, null); - - // Construct the message - Message msg = new MimeMessage(session); - msg.setFrom(new InternetAddress(smtpEmail)); - msg.setRecipient(Message.RecipientType.TO, new InternetAddress(emailAddress)); - msg.setSubject(subject); - msg.setText(body); - - // Send the message - Transport.send(msg); - } - -} diff --git a/vcell-rest/src/main/java/org/vcell/restq/db/UserRestDB.java b/vcell-rest/src/main/java/org/vcell/restq/db/UserRestDB.java index 70f965d558..6cf677d368 100644 --- a/vcell-rest/src/main/java/org/vcell/restq/db/UserRestDB.java +++ b/vcell-rest/src/main/java/org/vcell/restq/db/UserRestDB.java @@ -250,6 +250,9 @@ private Date getNewExpireDate() { public UserInfo getUserInfo(String userID) throws SQLException, DataAccessException { try { User user = adminDBTopLevel.getUser(userID, true); + if (user == null){ + return null; + } return adminDBTopLevel.getUserInfo(user.getID(), true); } catch (ObjectNotFoundException e) { return null;