修复用户登录
This commit is contained in:
parent
f14f45faf5
commit
0edffa145b
4 changed files with 10 additions and 8 deletions
|
|
@ -159,6 +159,7 @@ public class AuthController {
|
|||
* @return 商家信息
|
||||
*/
|
||||
@GetMapping("/profile")
|
||||
@Transactional(readOnly = true)
|
||||
public ApiResult<MerchantDto> getProfile(@AuthenticationPrincipal LoginUser loginUser) {
|
||||
if (loginUser.getMerchantId() == null) {
|
||||
return ApiResult.fail("商家信息不存在");
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import org.hibernate.annotations.Comment;
|
|||
@Table
|
||||
@Comment("商户信息表")
|
||||
public class Merchant extends AbstractBaseEntity {
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.xjhs.findmemerchant.security;
|
||||
|
||||
|
||||
import com.xjhs.findmemerchant.mapper.SystemUserMapper;
|
||||
import com.xjhs.findmemerchant.repository.MerchantRepository;
|
||||
import com.xjhs.findmemerchant.security.sms.SmsAuthenticationToken;
|
||||
import jakarta.servlet.FilterChain;
|
||||
|
|
@ -23,15 +24,16 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
|||
|
||||
private final JwtTokenService jwtTokenService;
|
||||
private final MerchantRepository merchantRepository;
|
||||
|
||||
private final SystemUserMapper systemUserMapper;
|
||||
|
||||
|
||||
private SmsAuthenticationToken getAuthenticationToken(String phone) throws Exception {
|
||||
// 手机号查商家
|
||||
var merchant = merchantRepository.findBySystemUserPhone(phone).orElse(null);
|
||||
if(merchant != null){
|
||||
if (merchant != null) {
|
||||
var authorities = List.of(new SimpleGrantedAuthority("ROLE_USER"));
|
||||
return new SmsAuthenticationToken(merchant, authorities);
|
||||
var loginUser = systemUserMapper.toLoginUserInfo(merchant.getSystemUser());
|
||||
return new SmsAuthenticationToken(loginUser, authorities);
|
||||
}
|
||||
throw new Exception("用户信息不存在");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@ public class RegisterVo {
|
|||
* 短信验证码
|
||||
*/
|
||||
@NotBlank
|
||||
@Size(max = 6, min = 6)
|
||||
@Size(max = 4, min = 4)
|
||||
private String code;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue