register working

This commit is contained in:
Tyro 2020-05-19 18:47:15 +02:00
parent 7686c4cda6
commit da78ab4990
1 changed files with 22 additions and 1 deletions

View File

@ -1,5 +1,7 @@
package org.hso.ecommerce.controller;
import org.hso.ecommerce.entities.booking.PaymentMethod;
import org.hso.ecommerce.entities.shop.Address;
import org.hso.ecommerce.entities.user.User;
import org.hso.ecommerce.repos.user.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
@ -45,10 +47,29 @@ public class RegisterController {
return "register";
}
//set values for new user
User newUser = new User();
newUser.email = username;
newUser.setPassword(password);
newUser.email = username;
if (type.equals("bus"))
newUser.isEmployee = true;
else
newUser.isEmployee = false;
newUser.isActive = true;
newUser.created = new java.sql.Timestamp(System.currentTimeMillis());
Address newAddress = new Address();
newAddress.name = name;
newAddress.addressString = address;
newUser.defaultDeliveryAddress = newAddress;
return "register";
PaymentMethod defaultPaymentMethod = PaymentMethod.fromCreditCarNumber("123456");
newUser.defaultPayment = defaultPaymentMethod;
userRepository.save(newUser); // save newUser
return "login";
}
@GetMapping("/register")