package com.ruoyi.framework.security.provider;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.PhoneUtils;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UserDetails;

public class MyDaoAuthenticationProvider extends DaoAuthenticationProvider {
    @Override
    protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
        if (PhoneUtils.isPhoneNumber(userDetails.getUsername()) && UserConstants.LOGIN_SMS_PASS.equals(userDetails.getPassword())) {
            return;
        }
        super.additionalAuthenticationChecks(userDetails, authentication);
    }
}

