patch connexion
This commit is contained in:
@@ -7,7 +7,7 @@ import java.util.List;
|
|||||||
public interface UserRepository {
|
public interface UserRepository {
|
||||||
List<UserProfil> findAll();
|
List<UserProfil> findAll();
|
||||||
UserProfil findById(int id);
|
UserProfil findById(int id);
|
||||||
UserProfil findByUsername(String username, String email);
|
UserProfil findByUsername(String username);
|
||||||
void save(UserProfil utilisateur);
|
void save(UserProfil utilisateur);
|
||||||
void delete(int id);
|
void delete(int id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
|||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
import org.springframework.jdbc.support.KeyHolder;
|
import org.springframework.jdbc.support.KeyHolder;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@@ -57,16 +58,9 @@ public class UserRepositoryImpl implements UserRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserProfil findByUsername(String username, String email) {
|
public UserProfil findByUsername(String username) {
|
||||||
UserProfil user = null;
|
String sql = "SELECT * FROM UTILISATEURS WHERE pseudo = ? OR email = ? AND isDelete = 0";
|
||||||
if (username != null) {
|
UserProfil user = jdbcTemplate.queryForObject(sql, new UserRowMapper(), username, username);
|
||||||
String sql = "SELECT * FROM UTILISATEURS WHERE pseudo = ? AND isDelete = 0";
|
|
||||||
user = jdbcTemplate.queryForObject(sql, new UserRowMapper(), username);
|
|
||||||
} else if (email != null) {
|
|
||||||
String sql = "SELECT * FROM UTILISATEURS WHERE email = ? AND isDelete = 0";
|
|
||||||
user = jdbcTemplate.queryForObject(sql, new UserRowMapper(), email);
|
|
||||||
}
|
|
||||||
System.out.println(user.getPassword());
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user