style: 优化社交身份认证注释为三方账号认证
This commit is contained in:
parent
a1ccc421c4
commit
d9af44f9fa
@ -69,7 +69,7 @@ public class CacheConsts {
|
|||||||
public static final String DASHBOARD_KEY_PREFIX = "DASHBOARD";
|
public static final String DASHBOARD_KEY_PREFIX = "DASHBOARD";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社交身份认证状态键前缀
|
* 三方账号认证状态键前缀
|
||||||
*/
|
*/
|
||||||
public static final String SOCIAL_AUTH_STATE_KEY_PREFIX = "SOCIAL_AUTH_STATE";
|
public static final String SOCIAL_AUTH_STATE_KEY_PREFIX = "SOCIAL_AUTH_STATE";
|
||||||
}
|
}
|
||||||
|
@ -42,10 +42,10 @@ public interface LoginService {
|
|||||||
String login(String username, String password);
|
String login(String username, String password);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社交身份登录
|
* 三方账号登录
|
||||||
*
|
*
|
||||||
* @param authUser
|
* @param authUser
|
||||||
* 社交身份信息
|
* 三方账号信息
|
||||||
* @return 令牌
|
* @return 令牌
|
||||||
*/
|
*/
|
||||||
String socialLogin(AuthUser authUser);
|
String socialLogin(AuthUser authUser);
|
||||||
|
@ -62,7 +62,7 @@ public interface UserSocialService {
|
|||||||
* 绑定
|
* 绑定
|
||||||
*
|
*
|
||||||
* @param authUser
|
* @param authUser
|
||||||
* 社交身份信息
|
* 三方账号信息
|
||||||
* @param userId
|
* @param userId
|
||||||
* 用户 ID
|
* 用户 ID
|
||||||
*/
|
*/
|
||||||
|
@ -53,7 +53,7 @@ const useUserStore = defineStore('user', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 社交身份登录
|
// 三方账号身份登录
|
||||||
async socialLogin(source: string, req: any) {
|
async socialLogin(source: string, req: any) {
|
||||||
try {
|
try {
|
||||||
const res = await userSocialLogin(source, req);
|
const res = await userSocialLogin(source, req);
|
||||||
|
@ -44,13 +44,13 @@ import me.zhyd.oauth.request.AuthRequest;
|
|||||||
import me.zhyd.oauth.utils.AuthStateUtils;
|
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 社交身份认证 API
|
* 三方账号认证 API
|
||||||
*
|
*
|
||||||
* @author Charles7c
|
* @author Charles7c
|
||||||
* @since 2023/10/8 22:52
|
* @since 2023/10/8 22:52
|
||||||
*/
|
*/
|
||||||
@Log(module = "登录")
|
@Log(module = "登录")
|
||||||
@Tag(name = "社交身份认证 API")
|
@Tag(name = "三方账号认证 API")
|
||||||
@SaIgnore
|
@SaIgnore
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ -60,7 +60,7 @@ public class SocialAuthController {
|
|||||||
private final LoginService loginService;
|
private final LoginService loginService;
|
||||||
private final AuthRequestFactory authRequestFactory;
|
private final AuthRequestFactory authRequestFactory;
|
||||||
|
|
||||||
@Operation(summary = "社交身份登录授权", description = "社交身份登录授权")
|
@Operation(summary = "三方账号登录授权", description = "三方账号登录授权")
|
||||||
@Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
|
@Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
|
||||||
@GetMapping("/{source}")
|
@GetMapping("/{source}")
|
||||||
public R authorize(@PathVariable String source) {
|
public R authorize(@PathVariable String source) {
|
||||||
@ -68,7 +68,7 @@ public class SocialAuthController {
|
|||||||
return R.ok("操作成功", authRequest.authorize(AuthStateUtils.createState()));
|
return R.ok("操作成功", authRequest.authorize(AuthStateUtils.createState()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "社交身份登录", description = "社交身份登录")
|
@Operation(summary = "三方账号登录", description = "三方账号登录")
|
||||||
@Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
|
@Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
|
||||||
@PostMapping("/{source}")
|
@PostMapping("/{source}")
|
||||||
public LoginVO login(@PathVariable String source, @RequestBody AuthCallback callback) {
|
public LoginVO login(@PathVariable String source, @RequestBody AuthCallback callback) {
|
||||||
@ -87,7 +87,7 @@ public class SocialAuthController {
|
|||||||
try {
|
try {
|
||||||
return authRequestFactory.get(source);
|
return authRequestFactory.get(source);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BadRequestException(String.format("暂不支持 [%s] 登录", source));
|
throw new BadRequestException(String.format("暂不支持 [%s] 平台账号登录", source));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -121,9 +121,9 @@ public class UserCenterController {
|
|||||||
return R.ok("修改成功");
|
return R.ok("修改成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询绑定的第三方账号", description = "查询绑定的第三方账号")
|
@Operation(summary = "查询绑定的三方账号", description = "查询绑定的三方账号")
|
||||||
@GetMapping("/social")
|
@GetMapping("/social")
|
||||||
public List<UserSocialBindVO> listSocial() {
|
public List<UserSocialBindVO> listSocialBind() {
|
||||||
List<UserSocialDO> userSocialList = userSocialService.listByUserId(LoginHelper.getUserId());
|
List<UserSocialDO> userSocialList = userSocialService.listByUserId(LoginHelper.getUserId());
|
||||||
return userSocialList.stream().map(userSocial -> {
|
return userSocialList.stream().map(userSocial -> {
|
||||||
String source = userSocial.getSource();
|
String source = userSocial.getSource();
|
||||||
@ -134,7 +134,7 @@ public class UserCenterController {
|
|||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "绑定第三方账号", description = "绑定第三方账号")
|
@Operation(summary = "绑定三方账号", description = "绑定三方账号")
|
||||||
@Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
|
@Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
|
||||||
@PostMapping("/social/{source}")
|
@PostMapping("/social/{source}")
|
||||||
public R bindSocial(@PathVariable String source, @RequestBody AuthCallback callback) {
|
public R bindSocial(@PathVariable String source, @RequestBody AuthCallback callback) {
|
||||||
@ -146,7 +146,7 @@ public class UserCenterController {
|
|||||||
return R.ok("绑定成功");
|
return R.ok("绑定成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "解绑第三方账号", description = "解绑第三方账号")
|
@Operation(summary = "解绑三方账号", description = "解绑三方账号")
|
||||||
@Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
|
@Parameter(name = "source", description = "来源", example = "gitee", in = ParameterIn.PATH)
|
||||||
@DeleteMapping("/social/{source}")
|
@DeleteMapping("/social/{source}")
|
||||||
public R unbindSocial(@PathVariable String source) {
|
public R unbindSocial(@PathVariable String source) {
|
||||||
|
Loading…
Reference in New Issue
Block a user