App用户注册完自动登录
This commit is contained in:
@@ -37,7 +37,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http
|
||||
.authorizeRequests()
|
||||
.antMatchers("/oauth/getPublicKey","/oauth/logout","/auth/getImgCode","/judgeToken/guangZhou").permitAll()
|
||||
.antMatchers("/oauth/getPublicKey","/oauth/logout","/auth/getImgCode","/judgeToken/guangZhou","/oauth/autoLogin").permitAll()
|
||||
// @link https://gitee.com/xiaoym/knife4j/issues/I1Q5X6 (接口文档knife4j需要放行的规则)
|
||||
.antMatchers("/webjars/**","/doc.html","/swagger-resources/**","/v2/api-docs").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import com.njcn.web.utils.RestTemplateUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@@ -28,8 +29,10 @@ import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
||||
import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.KeyPair;
|
||||
import java.security.Principal;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
@@ -148,5 +151,25 @@ public class AuthController extends BaseController {
|
||||
return new JWKSet(key).toJSONObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动登录
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.AUTHENTICATE)
|
||||
@ApiOperation("自动登录")
|
||||
@PostMapping("/autoLogin")
|
||||
@ApiImplicitParam(name = "phone", value = "手机号", required = true, paramType = "query")
|
||||
@ApiIgnore
|
||||
public HttpResult<Object> autoLogin(@RequestParam String phone) {
|
||||
String methodDescribe = getMethodDescribe("autoLogin");
|
||||
String userUrl = "http://127.0.0.1:10214/oauth/token";
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(userUrl)
|
||||
.queryParam("grant_type", "sms_code")
|
||||
.queryParam("client_id", "njcnapp")
|
||||
.queryParam("client_secret", "njcnpqs")
|
||||
.queryParam("phone", phone)
|
||||
.queryParam("smsCode", "123456789");
|
||||
URI uri = builder.build().encode().toUri();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, Objects.requireNonNull(RestTemplateUtil.post(uri, HttpResult.class).getBody()).getData(), methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user