fix nullpointer in settings

This commit is contained in:
Hannes Huber 2020-06-14 18:19:59 +02:00
parent fa610cae3b
commit 985169117d
1 changed files with 4 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package org.hso.ecommerce.controller;
import org.hso.ecommerce.action.user.UpdateUserSettingsAction;
import org.hso.ecommerce.entities.shop.Address;
import org.hso.ecommerce.entities.shop.CustomerOrder;
import org.hso.ecommerce.entities.user.User;
import org.hso.ecommerce.repos.shop.CustomerOrderRepository;
@ -38,6 +39,9 @@ public class UserController {
) {
long userId = (long) session.getAttribute("userId");
User user = userRepository.findById(userId).get();
if(user.defaultDeliveryAddress == null){
user.defaultDeliveryAddress = new Address();
}
model.addAttribute("user", user);
return "user/settings";