MCPcopy Create free account
hub / github.com/LQF-dev/smart-hr / login

Method login

back/src/main/java/com/smarthr/service/AuthService.java:41–61  ·  view source on GitHub ↗

用户登录

(LoginRequest request)

Source from the content-addressed store, hash-verified

39 * 用户登录
40 */
41 public AuthResponse login(LoginRequest request) {
42 log.info("User login attempt: {}", request.getUsername());
43
44 // 认证
45 Authentication authentication = authenticationManager.authenticate(
46 new UsernamePasswordAuthenticationToken(
47 request.getUsername(),
48 request.getPassword()
49 )
50 );
51
52 UserPrincipal userPrincipal = (UserPrincipal) authentication.getPrincipal();
53
54 // 生成 Token
55 String accessToken = jwtTokenProvider.generateToken(userPrincipal);
56 String refreshToken = jwtTokenProvider.generateRefreshToken(userPrincipal);
57
58 log.info("User logged in successfully: {}", request.getUsername());
59
60 return buildAuthResponse(userPrincipal, accessToken, refreshToken);
61 }
62
63 /**
64 * 用户注册

Callers 1

onFinishFunction · 0.45

Calls 5

buildAuthResponseMethod · 0.95
getUsernameMethod · 0.80
getPasswordMethod · 0.80
generateTokenMethod · 0.80
generateRefreshTokenMethod · 0.80

Tested by

no test coverage detected