Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
11f978b24c | |
|
|
b8654da5fb |
|
|
@ -32,7 +32,7 @@ export async function loginByOauth(params, context) {
|
||||||
filter: {
|
filter: {
|
||||||
state: stateCode,
|
state: stateCode,
|
||||||
},
|
},
|
||||||
}, { dontCollect: true });
|
}, { dontCollect: true, forUpdate: true }); // 这里直接加锁,防止其他人抢了
|
||||||
const systemId = context.getSystemId();
|
const systemId = context.getSystemId();
|
||||||
const [applicationPassport] = await context.select('applicationPassport', {
|
const [applicationPassport] = await context.select('applicationPassport', {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -96,7 +96,7 @@ export async function loginByOauth(params, context) {
|
||||||
providerUserId: oauthUserInfo.providerUserId,
|
providerUserId: oauthUserInfo.providerUserId,
|
||||||
providerConfigId: state.providerId,
|
providerConfigId: state.providerId,
|
||||||
}
|
}
|
||||||
}, { dontCollect: true });
|
}, { dontCollect: true, forUpdate: true }); // 加锁,防止并发绑定
|
||||||
// 已登录的情况
|
// 已登录的情况
|
||||||
if (islogginedIn) {
|
if (islogginedIn) {
|
||||||
// 检查当前用户是否已绑定此提供商
|
// 检查当前用户是否已绑定此提供商
|
||||||
|
|
|
||||||
|
|
@ -33,36 +33,6 @@ export default OakComponent({
|
||||||
const redirectUri = searchParams.get('redirect_uri') || '';
|
const redirectUri = searchParams.get('redirect_uri') || '';
|
||||||
const scope = searchParams.get('scope') || '';
|
const scope = searchParams.get('scope') || '';
|
||||||
const state = searchParams.get('state') || '';
|
const state = searchParams.get('state') || '';
|
||||||
//判断是否允许oauth登录
|
|
||||||
const application = this.features.application.getApplication();
|
|
||||||
const { result: applicationPassports } = await this.features.cache.exec('getApplicationPassports', { applicationId: application.id });
|
|
||||||
const oauthPassport = applicationPassports?.find((ele) => ele.passport?.type === 'oauth');
|
|
||||||
const oauthIds = oauthPassport?.config?.oauthIds;
|
|
||||||
let allowOauth = false;
|
|
||||||
if (clientId) {
|
|
||||||
const { data: [oauthProvider] } = await this.features.cache.refresh('oauthProvider', {
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
clientId: 1,
|
|
||||||
systemId: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
clientId,
|
|
||||||
systemId: application.systemId,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (oauthProvider?.id && oauthIds?.length > 0 && oauthIds.includes(oauthProvider?.id)) {
|
|
||||||
allowOauth = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!allowOauth) {
|
|
||||||
this.setState({
|
|
||||||
hasError: true,
|
|
||||||
errorMsg: 'oauth.login',
|
|
||||||
});
|
|
||||||
this.setState({ loading: false });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.setState({
|
this.setState({
|
||||||
client_id: clientId,
|
client_id: clientId,
|
||||||
response_type: responseType,
|
response_type: responseType,
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ async function loginByOauth(params, context) {
|
||||||
filter: {
|
filter: {
|
||||||
state: stateCode,
|
state: stateCode,
|
||||||
},
|
},
|
||||||
}, { dontCollect: true });
|
}, { dontCollect: true, forUpdate: true }); // 这里直接加锁,防止其他人抢了
|
||||||
const systemId = context.getSystemId();
|
const systemId = context.getSystemId();
|
||||||
const [applicationPassport] = await context.select('applicationPassport', {
|
const [applicationPassport] = await context.select('applicationPassport', {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -103,7 +103,7 @@ async function loginByOauth(params, context) {
|
||||||
providerUserId: oauthUserInfo.providerUserId,
|
providerUserId: oauthUserInfo.providerUserId,
|
||||||
providerConfigId: state.providerId,
|
providerConfigId: state.providerId,
|
||||||
}
|
}
|
||||||
}, { dontCollect: true });
|
}, { dontCollect: true, forUpdate: true }); // 加锁,防止并发绑定
|
||||||
// 已登录的情况
|
// 已登录的情况
|
||||||
if (islogginedIn) {
|
if (islogginedIn) {
|
||||||
// 检查当前用户是否已绑定此提供商
|
// 检查当前用户是否已绑定此提供商
|
||||||
|
|
|
||||||
10
package.json
10
package.json
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "oak-general-business",
|
"name": "oak-general-business",
|
||||||
"version": "5.11.1",
|
"version": "5.11.2",
|
||||||
"description": "oak框架中公共业务逻辑的实现",
|
"description": "oak框架中公共业务逻辑的实现",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "XuChang"
|
"name": "XuChang"
|
||||||
|
|
@ -23,10 +23,10 @@
|
||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
"dayjs": "^1.11.9",
|
"dayjs": "^1.11.9",
|
||||||
"nodemailer": "^6.9.14",
|
"nodemailer": "^6.9.14",
|
||||||
"oak-common-aspect": "^3.0.5",
|
"oak-common-aspect": "file:../oak-common-aspect",
|
||||||
"oak-domain": "^5.1.34",
|
"oak-domain": "file:../oak-domain",
|
||||||
"oak-external-sdk": "^2.3.12",
|
"oak-external-sdk": "file:../oak-external-sdk",
|
||||||
"oak-frontend-base": "^5.3.45",
|
"oak-frontend-base": "file:../oak-frontend-base",
|
||||||
"qrcode.react": "^3.1.0",
|
"qrcode.react": "^3.1.0",
|
||||||
"react-dnd": "^16.0.1",
|
"react-dnd": "^16.0.1",
|
||||||
"react-dnd-html5-backend": "^16.0.1",
|
"react-dnd-html5-backend": "^16.0.1",
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ export async function loginByOauth<ED extends EntityDict>(params: {
|
||||||
filter: {
|
filter: {
|
||||||
state: stateCode,
|
state: stateCode,
|
||||||
},
|
},
|
||||||
}, { dontCollect: true });
|
}, { dontCollect: true, forUpdate: true }); // 这里直接加锁,防止其他人抢了
|
||||||
|
|
||||||
const systemId = context.getSystemId();
|
const systemId = context.getSystemId();
|
||||||
const [applicationPassport] = await context.select('applicationPassport', {
|
const [applicationPassport] = await context.select('applicationPassport', {
|
||||||
|
|
@ -115,7 +115,7 @@ export async function loginByOauth<ED extends EntityDict>(params: {
|
||||||
providerUserId: oauthUserInfo.providerUserId,
|
providerUserId: oauthUserInfo.providerUserId,
|
||||||
providerConfigId: state.providerId!,
|
providerConfigId: state.providerId!,
|
||||||
}
|
}
|
||||||
}, { dontCollect: true })
|
}, { dontCollect: true, forUpdate: true }); // 加锁,防止并发绑定
|
||||||
|
|
||||||
// 已登录的情况
|
// 已登录的情况
|
||||||
if (islogginedIn) {
|
if (islogginedIn) {
|
||||||
|
|
|
||||||
|
|
@ -44,38 +44,6 @@ export default OakComponent({
|
||||||
const scope = searchParams.get('scope') || '';
|
const scope = searchParams.get('scope') || '';
|
||||||
const state = searchParams.get('state') || '';
|
const state = searchParams.get('state') || '';
|
||||||
|
|
||||||
//判断是否允许oauth登录
|
|
||||||
const application = this.features.application.getApplication();
|
|
||||||
const { result: applicationPassports } = await this.features.cache.exec('getApplicationPassports', { applicationId: application.id });
|
|
||||||
const oauthPassport = applicationPassports?.find((ele: EntityDict['applicationPassport']['Schema']) => ele.passport?.type === 'oauth');
|
|
||||||
const oauthIds = oauthPassport?.config?.oauthIds;
|
|
||||||
let allowOauth = false;
|
|
||||||
if (clientId) {
|
|
||||||
const { data: [oauthProvider] } = await this.features.cache.refresh('oauthProvider', {
|
|
||||||
data: {
|
|
||||||
id: 1,
|
|
||||||
clientId: 1,
|
|
||||||
systemId: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
clientId,
|
|
||||||
systemId: application.systemId,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (oauthProvider?.id && oauthIds?.length > 0 && oauthIds.includes(oauthProvider?.id)) {
|
|
||||||
allowOauth = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!allowOauth) {
|
|
||||||
this.setState({
|
|
||||||
hasError: true,
|
|
||||||
errorMsg: 'oauth.login',
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setState({ loading: false });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
client_id: clientId,
|
client_id: clientId,
|
||||||
response_type: responseType,
|
response_type: responseType,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue