• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

torresj / community-api / 6

28 May 2025 02:43PM UTC coverage: 75.157% (+53.1%) from 22.105%
6

push

circleci

Jaime Torres Benavente
Security added

87 of 133 new or added lines in 15 files covered. (65.41%)

239 of 318 relevant lines covered (75.16%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

11.11
/src/main/java/com/torresj/community/services/impl/LoginServiceImpl.java
1
package com.torresj.community.services.impl;
2

3
import com.torresj.community.dtos.ResponseLoginDto;
4
import com.torresj.community.entities.UserEntity;
5
import com.torresj.community.exceptions.LoginException;
6
import com.torresj.community.exceptions.UserNotFoundException;
7
import com.torresj.community.services.JwtService;
8
import com.torresj.community.services.LoginService;
9
import com.torresj.community.services.UserService;
10
import lombok.RequiredArgsConstructor;
11
import lombok.extern.slf4j.Slf4j;
12
import org.springframework.security.crypto.password.PasswordEncoder;
13
import org.springframework.stereotype.Service;
14

15
@Service
16
@Slf4j
1✔
17
@RequiredArgsConstructor
18
public class LoginServiceImpl implements LoginService {
19

20
    private final JwtService jwtService;
21
    private final PasswordEncoder encoder;
22
    private final UserService userService;
23

24
    @Override
25
    public ResponseLoginDto login(String name, String password) throws LoginException {
26
        try {
NEW
27
            log.debug("[LOGIN] Finding user");
×
NEW
28
            UserEntity userEntity = userService.getEntity(name);
×
NEW
29
            if (!encoder.matches(password, userEntity.getPassword())) {
×
NEW
30
                throw new LoginException();
×
31
            }
NEW
32
            log.debug("[LOGIN] Login success. Generating JWT ...");
×
NEW
33
            return new ResponseLoginDto(jwtService.createJWS(name));
×
NEW
34
        } catch (UserNotFoundException e) {
×
NEW
35
            throw new LoginException();
×
36
        }
37
    }
38
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc