mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
feat: support mobile login with WeChat Official Accounts (#383)
* fix: adjust the accessToken field Signed-off-by: 0x2a <stevesough@gmail.com> * fix: missing name and owner Signed-off-by: 0x2a <stevesough@gmail.com> * feat: support mobile login with WeChat Signed-off-by: 0x2a <stevesough@gmail.com>
This commit is contained in:
@ -179,6 +179,7 @@ func (idp *WeChatIdProvider) GetUserInfo(token *oauth2.Token) (*UserInfo, error)
|
|||||||
|
|
||||||
userInfo := UserInfo{
|
userInfo := UserInfo{
|
||||||
Id: id,
|
Id: id,
|
||||||
|
Username: wechatUserInfo.Nickname,
|
||||||
DisplayName: wechatUserInfo.Nickname,
|
DisplayName: wechatUserInfo.Nickname,
|
||||||
AvatarUrl: wechatUserInfo.Headimgurl,
|
AvatarUrl: wechatUserInfo.Headimgurl,
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ class ProviderEditPage extends React.Component {
|
|||||||
</Select>
|
</Select>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
{this.state.provider.type === "WeCom" ? (
|
{this.state.provider.type === "WeCom" || this.state.provider.type === "WeChat" ? (
|
||||||
<Row style={{marginTop: '20px'}} >
|
<Row style={{marginTop: '20px'}} >
|
||||||
<Col style={{marginTop: '5px'}} span={2}>
|
<Col style={{marginTop: '5px'}} span={2}>
|
||||||
{Setting.getLabel(i18next.t("provider:Method"), i18next.t("provider:Method - Tooltip"))} :
|
{Setting.getLabel(i18next.t("provider:Method"), i18next.t("provider:Method - Tooltip"))} :
|
||||||
|
@ -33,6 +33,8 @@ const authInfo = {
|
|||||||
WeChat: {
|
WeChat: {
|
||||||
scope: "snsapi_login",
|
scope: "snsapi_login",
|
||||||
endpoint: "https://open.weixin.qq.com/connect/qrconnect",
|
endpoint: "https://open.weixin.qq.com/connect/qrconnect",
|
||||||
|
slientScope: "snsapi_userinfo",
|
||||||
|
silentEndpoint: "https://open.weixin.qq.com/connect/oauth2/authorize"
|
||||||
},
|
},
|
||||||
Facebook: {
|
Facebook: {
|
||||||
scope: "email,public_profile",
|
scope: "email,public_profile",
|
||||||
@ -198,7 +200,13 @@ export function getAuthUrl(application, provider, method) {
|
|||||||
} else if (provider.type === "QQ") {
|
} else if (provider.type === "QQ") {
|
||||||
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
|
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
|
||||||
} else if (provider.type === "WeChat") {
|
} else if (provider.type === "WeChat") {
|
||||||
|
if (provider.method === "Silent") {
|
||||||
|
return `${authInfo[provider.type].silentEndpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&scope=${authInfo[provider.type].slientScope}&response_type=code#wechat_redirect`;
|
||||||
|
} else if (provider.method === "Normal") {
|
||||||
return `${endpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}#wechat_redirect`;
|
return `${endpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}#wechat_redirect`;
|
||||||
|
} else {
|
||||||
|
return `https://error:not-supported-provider-method:${provider.method}`;
|
||||||
|
}
|
||||||
} else if (provider.type === "Facebook") {
|
} else if (provider.type === "Facebook") {
|
||||||
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
|
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
|
||||||
} else if (provider.type === "DingTalk") {
|
} else if (provider.type === "DingTalk") {
|
||||||
|
Reference in New Issue
Block a user