Skip to content

Commit 737524e

Browse files
committed
implementing loadUserByUsername
1 parent 8227f2b commit 737524e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/main/java/com/appsdeveloperblog/app/ws/mobile_app_ws/service/impl/UserServiceImpl.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
import com.appsdeveloperblog.app.ws.mobile_app_ws.shared.dto.UserDto;
88
import org.springframework.beans.BeanUtils;
99
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.security.core.userdetails.User;
1011
import org.springframework.security.core.userdetails.UserDetails;
1112
import org.springframework.security.core.userdetails.UsernameNotFoundException;
1213
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
1314
import org.springframework.stereotype.Service;
1415

16+
import java.util.ArrayList;
17+
1518
@Service
1619
public class UserServiceImpl implements UserService {
1720

@@ -47,6 +50,8 @@ public UserDto createUser(UserDto user) {
4750

4851
@Override
4952
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
50-
return null;
53+
UserEntity userEntity=userRepository.findByEmail(username);
54+
if (userEntity==null) throw new UsernameNotFoundException(username);
55+
return new User(username,userEntity.getEncryptedPassword(),new ArrayList<>());
5156
}
5257
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.appsdeveloperblog.app.ws.mobile_app_ws.ui.model.request;
2+
3+
public class UserLoginRequestModel {
4+
private String email;
5+
private String password;
6+
7+
public String getEmail() {
8+
return email;
9+
}
10+
11+
public void setEmail(String email) {
12+
this.email = email;
13+
}
14+
15+
public String getPassword() {
16+
return password;
17+
}
18+
19+
public void setPassword(String password) {
20+
this.password = password;
21+
}
22+
}

0 commit comments

Comments
 (0)