Ignore:
Timestamp:
02/04/23 19:01:47 (22 months ago)
Author:
milamihajlovska <mila.mihajlovska01@…>
Branches:
master
Children:
e097c1c
Parents:
27adfc8
Message:

login method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/service/Impl/UserServiceImpl.java

    r27adfc8 r6032d44  
    3838    }
    3939
    40 //    @Override
    41 //    public User register(String first_name, String last_name, String username, String email, String number, String password, String role) {
    42 //        if(role.equals("worker"))
    43 //        {
    44 //            return userRepository.save(new Worker(passwordEncoder.encode(password),first_name,last_name,username,email,number));
    45 //        }
    46 //        else if (role.equals("user"))
    47 //            return userRepository.save(new Customer(passwordEncoder.encode(password),first_name,last_name,username,email,number));
    48 //    }
     40    @Override
     41    public User register(String first_name, String last_name, String username, String email, String number, String password, String role) {
     42        if(role.equals("worker"))
     43        {
     44            return userRepository.save(new Worker(passwordEncoder.encode(password),first_name,last_name,username,email,number));
     45        }
     46        else
     47            return userRepository.save(new Customer(passwordEncoder.encode(password),first_name,last_name,username,email,number));
     48    }
     49
     50    @Override
     51    public User login(String username, String password) {
     52        return userRepository.findAllByUsernameAndPassword(username,password).stream().findFirst().orElseThrow(UserNotFoundException::new);
     53    }
    4954
    5055
Note: See TracChangeset for help on using the changeset viewer.