1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-13 04:01:40 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

第三方登录添加 OSCHINA

This commit is contained in:
2022-04-04 21:02:30 +08:00
parent 5acd55c687
commit d78e1c6661
4 changed files with 16 additions and 36 deletions

View File

@@ -1,4 +1,5 @@
<button type="button" onclick="thirdPartyLogin('gitee')">Gitee</button>
<button type="button" onclick="thirdPartyLogin('OSCHINA')">OSCHINA</button>
<button type="button" onclick="thirdPartyLogin('qq')">QQ</button>
<script>
// 第三方授权登录逻辑

View File

@@ -16,6 +16,14 @@ public class ThirdPartyConfig {
@Value("${thirdparty.gitee.redirecturi}")
private String giteeRedirecturi;
// OSCHINA
@Value("${thirdparty.oschina.clientid}")
private String oschinaClientId;
@Value("${thirdparty.oschina.clientsecret}")
private String oschinaClientsecret;
@Value("${thirdparty.oschina.redirecturi}")
private String oschinaRedirecturi;
// QQ
@Value("${thirdparty.qq.clientid}")
private String qqClientid;

View File

@@ -7,6 +7,7 @@ import me.zhyd.oauth.exception.AuthException;
import me.zhyd.oauth.model.AuthCallback;
import me.zhyd.oauth.model.AuthResponse;
import me.zhyd.oauth.request.AuthGiteeRequest;
import me.zhyd.oauth.request.AuthOschinaRequest;
import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.utils.AuthStateUtils;
import org.apache.tomcat.jni.User;
@@ -93,6 +94,12 @@ public class ThirdPartyController extends BaseController {
.clientSecret(thirdPartyConfig.getGiteeClientsecret())
.redirectUri(thirdPartyConfig.getGiteeRedirecturi())
.build());
case "oschina":
return new AuthOschinaRequest(AuthConfig.builder()
.clientId(thirdPartyConfig.getOschinaClientId())
.clientSecret(thirdPartyConfig.getOschinaClientsecret())
.redirectUri(thirdPartyConfig.getOschinaRedirecturi())
.build());
case "qq":
return new AuthGiteeRequest(AuthConfig.builder()
.clientId(thirdPartyConfig.getQqClientid())

View File

@@ -16,9 +16,6 @@ import plus.bookshelf.Dao.Mapper.ThirdPartyUserAuthDOMapper;
import plus.bookshelf.Dao.Mapper.ThirdPartyUserDOMapper;
import plus.bookshelf.Service.Model.UserModel;
import plus.bookshelf.Service.Service.ThirdPartyUserService;
import plus.bookshelf.Service.Service.UserService;
import javax.annotation.Resource;
@Service
public class ThirdPartyUserServiceImpl implements ThirdPartyUserService {
@@ -193,39 +190,6 @@ public class ThirdPartyUserServiceImpl implements ThirdPartyUserService {
String screenName = token.getScreenName();
String oauthCallbackConfirmed = token.getOauthToken();
// String uuid = data.get("uuid").toString();
// String username = data.get("username").toString();
// String nickname = data.get("nickname").toString();
// String avatar = data.get("avatar").toString();
// String blog = data.get("blog").toString();
// String company = data.get("company").toString();
// String location = data.get("location").toString();
// String email = data.get("email").toString();
// String remark = data.get("remark").toString();
// String gender = data.get("gender").toString();
// String source = data.get("source").toString();
// Map token = (Map) data.get("token");
// String accessToken = token.get("accessToken").toString();
// int expiresIn = Integer.parseInt(token.get("expiresIn").toString());
// String refreshToken = token.get("refreshToken").toString();
// int refreshTokenExpireIn = Integer.parseInt(token.get("refreshTokenExpireIn").toString());
// String uid = token.get("uid").toString();
// String openId = token.get("openId").toString();
// String accessCode = token.get("accessCode").toString();
// String unionId = token.get("unionId").toString();
// String scope = token.get("scope").toString();
// String tokenType = token.get("tokenType").toString();// token 类型,默认为 bearer
// String idToken = token.get("idToken").toString();// id_token
// String macAlgorithm = token.get("macAlgorithm").toString();// mac 算法
// String macKey = token.get("macKey").toString();// mac 密钥
// String code = token.get("code").toString();// code
// String oauthToken = token.get("oauthToken").toString();// oauth_token
// String oauthTokenSecret = token.get("oauthTokenSecret").toString();// oauth_token_secret
// String userId = token.get("userId").toString();// user_id
// String screenName = token.get("screenName").toString();// screen_name
// String oauthCallbackConfirmed = token.get("oauthCallbackConfirmed").toString();// oauth_callback_confirmed
ThirdPartyUserDO thirdPartyUserDO = new ThirdPartyUserDO();
thirdPartyUserDO.setUuid(uuid);
thirdPartyUserDO.setSource(source);