feature/register #24

Merged
Seil0 merged 3 commits from feature/register into master 2020-05-25 10:51:33 +02:00
Showing only changes of commit da78ab4990 - Show all commits

View File

@ -1,5 +1,7 @@
package org.hso.ecommerce.controller; 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.entities.user.User;
import org.hso.ecommerce.repos.user.UserRepository; import org.hso.ecommerce.repos.user.UserRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -45,10 +47,29 @@ public class RegisterController {
return "register"; return "register";
} }
//set values for new user
User newUser = 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") @GetMapping("/register")