- Timestamp:
- 05/05/24 01:27:16 (6 months ago)
- Branches:
- master
- Children:
- baf4cc4
- Parents:
- 4d026a5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/mk/ukim/finki/busngo/service/impl/AuthServiceImpl.java
r4d026a5 r8b875e6 5 5 import mk.ukim.finki.busngo.model.entities.Patnik; 6 6 import mk.ukim.finki.busngo.model.entities.Vozac; 7 import mk.ukim.finki.busngo.model.enums.Role; 7 8 import mk.ukim.finki.busngo.model.enums.VrabotenType; 8 9 import mk.ukim.finki.busngo.model.exceptions.InvalidCredentialsException; … … 128 129 } 129 130 131 @Override 132 public Korisnik register(String name, String email, String password, String confirmPassword, String address, String phone, Role role, Double salary) { 133 if (email == null || password == null || email.isEmpty() || password.isEmpty()) { 134 throw new InvalidCredentialsException(); 135 } 136 137 if(!password.equals(confirmPassword)){ 138 throw new InvalidCredentialsException(); 139 } 140 141 if(role.equals(Role.ROLE_DRIVER)){ 142 Vozac vozac = new Vozac(); 143 vozac.setKIme(name); 144 vozac.setKAdresa(address); 145 vozac.setKLozinka(passwordEncoder.encode(password)); 146 vozac.setKEmail(email); 147 vozac.setKTelefon(phone); 148 vozac.setKIsAdmin(role.equals(Role.ROLE_ADMIN)); 149 vozac.setKRole(role); 150 vozac.setVPlata(salary != null ? salary : 0.0); 151 vozac.setVDatumNaVrabotuvanje(Date.valueOf(LocalDate.now())); 152 this.korisnikRepository.save(vozac); 153 return vozacRepository.save(vozac); 154 } else if(role.equals(Role.ROLE_CONDUCTOR)){ 155 Kondukter kondukter = new Kondukter(); 156 kondukter.setKIme(name); 157 kondukter.setKAdresa(address); 158 kondukter.setKLozinka(passwordEncoder.encode(password)); 159 kondukter.setKEmail(email); 160 kondukter.setKTelefon(phone); 161 kondukter.setKIsAdmin(role.equals(Role.ROLE_ADMIN)); 162 kondukter.setKRole(role); 163 kondukter.setVPlata(salary != null ? salary : 0.0); 164 kondukter.setVDatumNaVrabotuvanje(Date.valueOf(LocalDate.now())); 165 this.korisnikRepository.save(kondukter); 166 return kondukterRepository.save(kondukter); 167 } else { 168 Patnik patnik = new Patnik(); 169 patnik.setKIme(name); 170 patnik.setKAdresa(address); 171 patnik.setKLozinka(passwordEncoder.encode(password)); 172 patnik.setKEmail(email); 173 patnik.setKTelefon(phone); 174 patnik.setKIsAdmin(role.equals(Role.ROLE_ADMIN)); 175 patnik.setKRole(role); 176 this.korisnikRepository.save(patnik); 177 return patnikRepository.save(patnik); 178 } 179 } 180 130 181 131 182 }
Note:
See TracChangeset
for help on using the changeset viewer.