first commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.metalloop.common.auth.handler;
|
||||
|
||||
|
||||
import com.metalloop.common.auth.Authentication;
|
||||
import com.metalloop.common.model.Result;
|
||||
import com.metalloop.modules.auth.model.resp.AuthenticationResponse;
|
||||
|
||||
/**
|
||||
* 登录成功处理器默认实现
|
||||
*
|
||||
* @author zhaowenhao
|
||||
* @since 2023-03-19
|
||||
*/
|
||||
public class DefaultLoginSuccessHandler implements LoginSuccessHandler {
|
||||
@Override
|
||||
public Object onSuccess(Authentication authentication) {
|
||||
AuthenticationResponse authenticationResponse = new AuthenticationResponse();
|
||||
authenticationResponse.setAccessToken(authentication.getAccessToken());
|
||||
authenticationResponse.setUsername(authentication.getUsername());
|
||||
authenticationResponse.setUserId(authentication.getUserId());
|
||||
return Result.ok(authenticationResponse);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.metalloop.common.auth.handler;
|
||||
|
||||
|
||||
import com.metalloop.common.auth.Authentication;
|
||||
import com.metalloop.common.model.Result;
|
||||
|
||||
/**
|
||||
* 登出成功处理器默认实现
|
||||
*
|
||||
* @author zhaowenhao
|
||||
* @since 2023-03-19
|
||||
*/
|
||||
public class DefaultLogoutSuccessHandler implements LogoutSuccessHandler {
|
||||
@Override
|
||||
public Object onSuccess(Authentication authentication) {
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.metalloop.common.auth.handler;
|
||||
|
||||
|
||||
import com.metalloop.common.auth.userdetails.UserDetails;
|
||||
|
||||
/**
|
||||
* 密码校验失败处理器默认实现
|
||||
*
|
||||
* @author lifan
|
||||
* @date 2024/3/26 18:04
|
||||
*/
|
||||
public class DefaultPasswordCheckFailureHandler implements PasswordCheckFailureHandler {
|
||||
|
||||
@Override
|
||||
public void onFailure(String ip, UserDetails userDetails) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String ip, UserDetails userDetails) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkAccountLockStatus(String ip, UserDetails userDetails) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.metalloop.common.auth.handler;
|
||||
|
||||
public class DefaultVerifyCodeHandler implements VerifyCodeHandler{
|
||||
|
||||
|
||||
@Override
|
||||
public boolean createVerifyCode(String phoneNum) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkVerifyCode(String phoneNum, String verifyCode) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.metalloop.common.auth.handler;
|
||||
|
||||
|
||||
import com.metalloop.common.auth.Authentication;
|
||||
|
||||
/**
|
||||
* 登录成功处理器
|
||||
*
|
||||
* @author zhaowenhao
|
||||
* @since 2023-03-19
|
||||
*/
|
||||
public interface LoginSuccessHandler {
|
||||
|
||||
/**
|
||||
* 处理登录成功的情况,例如生成令牌、返回用户信息等。
|
||||
*
|
||||
* @param authentication 认证信息
|
||||
* @return 登录成功后的响应对象
|
||||
*/
|
||||
Object onSuccess(Authentication authentication);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.metalloop.common.auth.handler;
|
||||
|
||||
|
||||
import com.metalloop.common.auth.Authentication;
|
||||
|
||||
/**
|
||||
* 登出成功处理器
|
||||
*
|
||||
* @author zhaowenhao
|
||||
* @since 2023-03-19
|
||||
*/
|
||||
public interface LogoutSuccessHandler {
|
||||
|
||||
/**
|
||||
* 处理登出成功的情况,认证信息可能为null
|
||||
*
|
||||
* @param authentication 认证信息,可能为null
|
||||
* @return 登录成功后的响应对象
|
||||
*/
|
||||
Object onSuccess(Authentication authentication);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.metalloop.common.auth.handler;
|
||||
|
||||
|
||||
import com.metalloop.common.auth.userdetails.UserDetails;
|
||||
|
||||
/**
|
||||
* @author lifan
|
||||
* @date 2024/3/26 17:58
|
||||
*/
|
||||
public interface PasswordCheckFailureHandler {
|
||||
|
||||
/**
|
||||
* 处理密码校验失败的情况
|
||||
*
|
||||
* @param ip 用户ip
|
||||
* @param userDetails 账户信息
|
||||
*/
|
||||
void onFailure(String ip, UserDetails userDetails);
|
||||
|
||||
/**
|
||||
* 处理密码校验成功的情况
|
||||
*
|
||||
* @param ip 用户ip
|
||||
* @param userDetails 账户信息
|
||||
*/
|
||||
void onSuccess(String ip, UserDetails userDetails);
|
||||
|
||||
/**
|
||||
* 检查账户锁定状态
|
||||
*
|
||||
* @param ip 用户ip
|
||||
* @param userDetails 账户信息
|
||||
*/
|
||||
void checkAccountLockStatus(String ip, UserDetails userDetails);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.metalloop.common.auth.handler;
|
||||
|
||||
public interface VerifyCodeHandler {
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
*
|
||||
* @param phoneNum 手机号
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean createVerifyCode(String phoneNum);
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param phoneNum 手机号
|
||||
* @param verifyCode 待校验的验证码
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean checkVerifyCode(String phoneNum, String verifyCode);
|
||||
}
|
||||
Reference in New Issue
Block a user