feature/register #24
@ -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;
 | 
			
		||||
| 
					
	
	
	
	
	
	
	
	 
				
					
						Seil0
						commented  
			
		
 `defaultPaymentMethod` braucht man nicht. 
			
			
		 | 
			||||
 | 
			
		||||
        userRepository.save(newUser); // save newUser
 | 
			
		||||
 | 
			
		||||
        return "login";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/register")
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user
	
Entweder mit Klammern oder (noch besser) vereinfachen.