优化短信登录配置
This commit is contained in:
parent
50f8921318
commit
575340ec49
|
@ -0,0 +1,38 @@
|
||||||
|
package net.maku.security.config;
|
||||||
|
|
||||||
|
import net.maku.api.module.message.SmsApi;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录配置信息
|
||||||
|
*
|
||||||
|
* @author 阿沐 babamu@126.com
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class LoginConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
SmsApi smsApi() {
|
||||||
|
return new SmsApi() {
|
||||||
|
@Override
|
||||||
|
public boolean send(String mobile, Map<String, String> params) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean sendCode(String mobile, String key, String value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean verifyCode(String mobile, String code) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,7 +47,10 @@ public class SysAuthController {
|
||||||
@PostMapping("send/code")
|
@PostMapping("send/code")
|
||||||
@Operation(summary = "发送短信验证码")
|
@Operation(summary = "发送短信验证码")
|
||||||
public Result<String> sendCode(String mobile) {
|
public Result<String> sendCode(String mobile) {
|
||||||
sysAuthService.sendCode(mobile);
|
boolean flag = sysAuthService.sendCode(mobile);
|
||||||
|
if (!flag) {
|
||||||
|
return Result.error("短信发送失败!");
|
||||||
|
}
|
||||||
|
|
||||||
return Result.ok();
|
return Result.ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public interface SysAuthService {
|
||||||
*
|
*
|
||||||
* @param mobile 手机号
|
* @param mobile 手机号
|
||||||
*/
|
*/
|
||||||
void sendCode(String mobile);
|
boolean sendCode(String mobile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出登录
|
* 退出登录
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendCode(String mobile) {
|
public boolean sendCode(String mobile) {
|
||||||
// 生成6位验证码
|
// 生成6位验证码
|
||||||
String code = RandomUtil.randomNumbers(6);
|
String code = RandomUtil.randomNumbers(6);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public class SysAuthServiceImpl implements SysAuthService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送短信
|
// 发送短信
|
||||||
smsApi.sendCode(mobile, "code", code);
|
return smsApi.sendCode(mobile, "code", code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,11 +25,11 @@
|
||||||
<!-- <artifactId>maku-module-quartz</artifactId>-->
|
<!-- <artifactId>maku-module-quartz</artifactId>-->
|
||||||
<!-- <version>${revision}</version>-->
|
<!-- <version>${revision}</version>-->
|
||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>net.maku</groupId>
|
<!-- <groupId>net.maku</groupId>-->
|
||||||
<artifactId>maku-module-message</artifactId>
|
<!-- <artifactId>maku-module-message</artifactId>-->
|
||||||
<version>${revision}</version>
|
<!-- <version>${revision}</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
<artifactId>knife4j-springdoc-ui</artifactId>
|
<artifactId>knife4j-springdoc-ui</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user