Skip to content

Commit 9b520b9

Browse files
committed
I almost have completed
1 parent 1a7d740 commit 9b520b9

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/main/java/mate/academy/dao/impl/UserDaoImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public User get(Long id) {
4343
@Override
4444
public Optional<User> findByEmail(String email) {
4545
try (Session session = HibernateUtil.getSessionFactory().openSession()) {
46-
Query<User> query = session.createQuery("from User, User.class where email"
46+
Query<User> query = session.createQuery("from User where email"
4747
+ "=:email");
4848
query.setParameter("email", email);
49-
return Optional.ofNullable(query.uniqueResult());
49+
return query.uniqueResultOptional();
5050
} catch (Exception exception) {
5151
throw new RuntimeException("Cannot get user", exception);
5252
}

src/main/java/mate/academy/security/impl/AuthenticationServiceImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ public class AuthenticationServiceImpl implements AuthenticationService {
1616
@Override
1717
public User login(String email, String password) throws AuthenticationException {
1818
Optional<User> byEmail = userService.findByEmail(email);
19-
if (byEmail.isEmpty()) {
20-
throw new AuthenticationException("Invalid email");
21-
}
2219
User user = byEmail.get();
2320
String hashedPassword = HashUtil.hashPassword(password, user.getSalt());
2421
if (!hashedPassword.equals(user.getPassword()) || byEmail.isEmpty()) {

0 commit comments

Comments
 (0)