draft for borrow, update partey tags, added jwt

This commit is contained in:
2021-10-22 10:56:20 +02:00
parent 442bdb4996
commit a24f0650d1
41 changed files with 3415 additions and 162 deletions
@@ -8,6 +8,13 @@ import org.springframework.mail.MailMessage;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import de.bstly.we.businesslogic.UserManager;
import de.bstly.we.businesslogic.UserProfileFieldManager;
import de.bstly.we.businesslogic.UserProfileFields;
import de.bstly.we.model.User;
import de.bstly.we.model.UserProfileField;
/**
* The Class EmailManager.
@@ -17,6 +24,10 @@ public class EmailManager {
@Autowired
private JavaMailSender javaMailSender;
@Autowired
private UserManager userManager;
@Autowired
private UserProfileFieldManager userProfileFieldManager;
/**
* Send text.
@@ -57,4 +68,28 @@ public class EmailManager {
return message;
}
/**
* Gets the user email.
*
* @param user the user
* @return the user email
*/
public String getUserEmail(User user) {
String email = userManager.getBstlyEmail(user.getUsername());
UserProfileField primaryEmailUserProfileField = userProfileFieldManager.get(user.getId(),
UserProfileFields.PROFILE_FIELD_EMAIL_PRIMARY);
if (primaryEmailUserProfileField != null
&& "true".equals(primaryEmailUserProfileField.getValue())) {
UserProfileField emailUserProfileField = userProfileFieldManager.get(user.getId(),
UserProfileFields.PROFILE_FIELD_EMAIL);
if (emailUserProfileField != null
&& StringUtils.hasText(emailUserProfileField.getValue())) {
email = emailUserProfileField.getValue();
}
}
return email;
}
}
@@ -74,19 +74,7 @@ public class EmailController extends BaseController {
continue;
}
String email = userManager.getBstlyEmail(user.getUsername());
UserProfileField primaryEmailUserProfileField = userProfileFieldManager
.get(user.getId(), UserProfileFields.PROFILE_FIELD_EMAIL_PRIMARY);
if (primaryEmailUserProfileField != null
&& "true".equals(primaryEmailUserProfileField.getValue())) {
UserProfileField emailUserProfileField = userProfileFieldManager.get(user.getId(),
UserProfileFields.PROFILE_FIELD_EMAIL);
if (emailUserProfileField != null
&& StringUtils.hasText(emailUserProfileField.getValue())) {
email = emailUserProfileField.getValue();
}
}
String email = emailManager.getUserEmail(user);
UserMailModel userMailModel = new UserMailModel(user.getUsername(), email);
@@ -95,7 +83,6 @@ public class EmailController extends BaseController {
if (localeUserProfileField != null
&& StringUtils.hasText(localeUserProfileField.getValue())) {
userMailModel.setLocale(localeUserProfileField.getValue());
}
result.add(userMailModel);
@@ -104,4 +91,6 @@ public class EmailController extends BaseController {
return result;
}
}