liujie
2026-09-11 4f6f15b818704079ff2e4e4719b798f48d68a335
backend/src/main/java/com/tourguide/modules/user/service/AuthService.java
@@ -21,6 +21,7 @@
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.nio.charset.StandardCharsets;
import java.util.List;
@@ -134,12 +135,20 @@
    private GuideUser findLoginableGuideByPhone(String phone) {
        GuideUser user = guideUserService.findByPhone(phone);
        validateGuideLoginStatus(user, "手机号未注册");
        validateGuideLoginPhone(user, phone);
        guideAutoDisableService.disableGuideIfEligible(user.getId());
        GuideUser currentUser = guideUserService.findByPhone(phone);
        validateGuideLoginStatus(currentUser, "手机号未注册");
        validateGuideLoginPhone(currentUser, phone);
        return currentUser;
    }
    private void validateGuideLoginPhone(GuideUser user, String phone) {
        if (StringUtils.hasText(user.getMobile()) && !phone.equals(user.getMobile())) {
            throw new BusinessException(401, "手机号未注册");
        }
    }
    private void validateGuideLoginStatus(GuideUser user, String notFoundMessage) {
        if (user == null) {
            throw new BusinessException(401, notFoundMessage);