登录修改
This commit is contained in:
parent
b006071133
commit
892dd2080b
|
|
@ -247,5 +247,8 @@ export type AspectDict<ED extends EntityDict> = {
|
|||
systemId: string;
|
||||
origin: EntityDict['smsTemplate']['Schema']['origin'];
|
||||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||||
getApplicationPassports: (params: {
|
||||
applicationId: string;
|
||||
}, context: BackendRuntimeContext<ED>) => Promise<EntityDict['applicationPassport']['Schema'][]>;
|
||||
};
|
||||
export default AspectDict;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
import { EntityDict } from "../oak-app-domain";
|
||||
import { BRC } from '../types/RuntimeCxt';
|
||||
export declare function getApplicationPassports<ED extends EntityDict>(params: {
|
||||
applicationId: string;
|
||||
}, context: BRC<ED>): Promise<Partial<ED["applicationPassport"]["Schema"]>[]>;
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
export async function getApplicationPassports(params, context) {
|
||||
const { applicationId } = params;
|
||||
const closeRoot = context.openRootMode();
|
||||
const applicationPassports = await context.select('applicationPassport', {
|
||||
data: {
|
||||
id: 1,
|
||||
passportId: 1,
|
||||
passport: {
|
||||
id: 1,
|
||||
type: 1,
|
||||
config: 1,
|
||||
},
|
||||
isDefault: 1,
|
||||
},
|
||||
filter: {
|
||||
applicationId,
|
||||
}
|
||||
}, {});
|
||||
closeRoot();
|
||||
return applicationPassports;
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ import { getCurrentMenu, getMenu, createMenu, createConditionalMenu, deleteCondi
|
|||
import { createTag, getTags, editTag, deleteTag, syncTag, oneKeySync } from './wechatPublicTag';
|
||||
import { getTagUsers, batchtagging, batchuntagging, getUserTags, getUsers, tagging, syncToLocale, syncToWechat } from './userWechatPublicTag';
|
||||
import { wechatMpJump } from './wechatMpJump';
|
||||
import { getApplicationPassports } from './applicationPassport';
|
||||
declare const aspectDict: {
|
||||
mergeUser: typeof mergeUser;
|
||||
switchTo: typeof switchTo;
|
||||
|
|
@ -69,6 +70,7 @@ declare const aspectDict: {
|
|||
syncToWechat: typeof syncToWechat;
|
||||
wechatMpJump: typeof wechatMpJump;
|
||||
syncSmsTemplate: typeof syncSmsTemplate;
|
||||
getApplicationPassports: typeof getApplicationPassports;
|
||||
};
|
||||
export default aspectDict;
|
||||
export { AspectDict } from './AspectDict';
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import { getCurrentMenu, getMenu, createMenu, createConditionalMenu, deleteCondi
|
|||
import { createTag, getTags, editTag, deleteTag, syncTag, oneKeySync, } from './wechatPublicTag';
|
||||
import { getTagUsers, batchtagging, batchuntagging, getUserTags, getUsers, tagging, syncToLocale, syncToWechat, } from './userWechatPublicTag';
|
||||
import { wechatMpJump, } from './wechatMpJump';
|
||||
import { getApplicationPassports } from './applicationPassport';
|
||||
const aspectDict = {
|
||||
mergeUser,
|
||||
switchTo,
|
||||
|
|
@ -68,6 +69,7 @@ const aspectDict = {
|
|||
syncToLocale,
|
||||
syncToWechat,
|
||||
wechatMpJump,
|
||||
syncSmsTemplate
|
||||
syncSmsTemplate,
|
||||
getApplicationPassports,
|
||||
};
|
||||
export default aspectDict;
|
||||
|
|
|
|||
|
|
@ -875,7 +875,7 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) {
|
|||
// wechatUser存在直接登录
|
||||
if (wechatUser) {
|
||||
const tokenValue = await setUpTokenAndUser(env, context, 'wechatUser', wechatUser.id, undefined, wechatUser.user);
|
||||
await updateWechatLogin({ successed: true });
|
||||
await updateWechatLogin({ userId: wechatUser.userId, successed: true });
|
||||
return tokenValue;
|
||||
}
|
||||
else {
|
||||
|
|
@ -1376,8 +1376,8 @@ export async function refreshToken(params, context) {
|
|||
// 只有server模式去刷新token
|
||||
// 'development' | 'production' | 'staging'
|
||||
const intervals = {
|
||||
development: 7200 * 1000, // 2小时
|
||||
staging: 600 * 1000, // 十分钟
|
||||
development: 7200 * 1000,
|
||||
staging: 600 * 1000,
|
||||
production: 600 * 1000, // 十分钟
|
||||
};
|
||||
const application = context.getApplication();
|
||||
|
|
|
|||
|
|
@ -19,12 +19,25 @@ export async function createWechatLogin(params, context) {
|
|||
userId,
|
||||
});
|
||||
}
|
||||
await context.operate('wechatLogin', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: createData,
|
||||
}, {
|
||||
dontCollect: true,
|
||||
});
|
||||
if (type === 'login') {
|
||||
const closeRoot = context.openRootMode();
|
||||
await context.operate('wechatLogin', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: createData,
|
||||
}, {
|
||||
dontCollect: true,
|
||||
});
|
||||
closeRoot();
|
||||
}
|
||||
else {
|
||||
await context.operate('wechatLogin', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: createData,
|
||||
}, {
|
||||
dontCollect: true,
|
||||
});
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ import { EntityDict } from '../../../oak-app-domain';
|
|||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, keyof EntityDict, false, {
|
||||
type: "login" | "bind";
|
||||
url: string;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ export default OakComponent({
|
|||
id: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
type: 1, //类型
|
||||
type: 1,
|
||||
ticket: 1,
|
||||
url: 1,
|
||||
buffer: 1,
|
||||
|
|
@ -130,7 +130,7 @@ export default OakComponent({
|
|||
id: wechatLoginId,
|
||||
},
|
||||
});
|
||||
const { successed, type } = wechatLogin;
|
||||
const { successed, type } = wechatLogin || {};
|
||||
this.setState({
|
||||
successful: successed,
|
||||
type,
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ const triggers = [
|
|||
case 'wechatPublic': {
|
||||
assert(applicationType === 'wechatPublic' &&
|
||||
config.type === 'wechatPublic');
|
||||
if (process.env.OAK_PLATFORM === 'web') {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
Object.assign(updateData, {
|
||||
ticket: 'develop环境下无法真实获取二维码数据',
|
||||
url: `http://localhost:3000/wechatQrCode/scan?scene=${shrinkUuidTo32Bytes(id)}`,
|
||||
|
|
|
|||
|
|
@ -247,5 +247,8 @@ export type AspectDict<ED extends EntityDict> = {
|
|||
systemId: string;
|
||||
origin: EntityDict['smsTemplate']['Schema']['origin'];
|
||||
}, context: BackendRuntimeContext<ED>) => Promise<void>;
|
||||
getApplicationPassports: (params: {
|
||||
applicationId: string;
|
||||
}, context: BackendRuntimeContext<ED>) => Promise<EntityDict['applicationPassport']['Schema'][]>;
|
||||
};
|
||||
export default AspectDict;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
import { EntityDict } from "../oak-app-domain";
|
||||
import { BRC } from '../types/RuntimeCxt';
|
||||
export declare function getApplicationPassports<ED extends EntityDict>(params: {
|
||||
applicationId: string;
|
||||
}, context: BRC<ED>): Promise<Partial<ED["applicationPassport"]["Schema"]>[]>;
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getApplicationPassports = void 0;
|
||||
async function getApplicationPassports(params, context) {
|
||||
const { applicationId } = params;
|
||||
const closeRoot = context.openRootMode();
|
||||
const applicationPassports = await context.select('applicationPassport', {
|
||||
data: {
|
||||
id: 1,
|
||||
passportId: 1,
|
||||
passport: {
|
||||
id: 1,
|
||||
type: 1,
|
||||
config: 1,
|
||||
},
|
||||
isDefault: 1,
|
||||
},
|
||||
filter: {
|
||||
applicationId,
|
||||
}
|
||||
}, {});
|
||||
closeRoot();
|
||||
return applicationPassports;
|
||||
}
|
||||
exports.getApplicationPassports = getApplicationPassports;
|
||||
|
|
@ -13,6 +13,7 @@ import { getCurrentMenu, getMenu, createMenu, createConditionalMenu, deleteCondi
|
|||
import { createTag, getTags, editTag, deleteTag, syncTag, oneKeySync } from './wechatPublicTag';
|
||||
import { getTagUsers, batchtagging, batchuntagging, getUserTags, getUsers, tagging, syncToLocale, syncToWechat } from './userWechatPublicTag';
|
||||
import { wechatMpJump } from './wechatMpJump';
|
||||
import { getApplicationPassports } from './applicationPassport';
|
||||
declare const aspectDict: {
|
||||
mergeUser: typeof mergeUser;
|
||||
switchTo: typeof switchTo;
|
||||
|
|
@ -69,6 +70,7 @@ declare const aspectDict: {
|
|||
syncToWechat: typeof syncToWechat;
|
||||
wechatMpJump: typeof wechatMpJump;
|
||||
syncSmsTemplate: typeof syncSmsTemplate;
|
||||
getApplicationPassports: typeof getApplicationPassports;
|
||||
};
|
||||
export default aspectDict;
|
||||
export { AspectDict } from './AspectDict';
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ const wechatMenu_1 = require("./wechatMenu");
|
|||
const wechatPublicTag_1 = require("./wechatPublicTag");
|
||||
const userWechatPublicTag_1 = require("./userWechatPublicTag");
|
||||
const wechatMpJump_1 = require("./wechatMpJump");
|
||||
const applicationPassport_1 = require("./applicationPassport");
|
||||
const aspectDict = {
|
||||
mergeUser: user_1.mergeUser,
|
||||
switchTo: token_1.switchTo,
|
||||
|
|
@ -70,6 +71,7 @@ const aspectDict = {
|
|||
syncToLocale: userWechatPublicTag_1.syncToLocale,
|
||||
syncToWechat: userWechatPublicTag_1.syncToWechat,
|
||||
wechatMpJump: wechatMpJump_1.wechatMpJump,
|
||||
syncSmsTemplate: sms_1.syncSmsTemplate
|
||||
syncSmsTemplate: sms_1.syncSmsTemplate,
|
||||
getApplicationPassports: applicationPassport_1.getApplicationPassports,
|
||||
};
|
||||
exports.default = aspectDict;
|
||||
|
|
|
|||
|
|
@ -882,7 +882,7 @@ async function loginFromWechatEnv(code, env, context, wechatLoginId) {
|
|||
// wechatUser存在直接登录
|
||||
if (wechatUser) {
|
||||
const tokenValue = await setUpTokenAndUser(env, context, 'wechatUser', wechatUser.id, undefined, wechatUser.user);
|
||||
await updateWechatLogin({ successed: true });
|
||||
await updateWechatLogin({ userId: wechatUser.userId, successed: true });
|
||||
return tokenValue;
|
||||
}
|
||||
else {
|
||||
|
|
@ -1391,8 +1391,8 @@ async function refreshToken(params, context) {
|
|||
// 只有server模式去刷新token
|
||||
// 'development' | 'production' | 'staging'
|
||||
const intervals = {
|
||||
development: 7200 * 1000, // 2小时
|
||||
staging: 600 * 1000, // 十分钟
|
||||
development: 7200 * 1000,
|
||||
staging: 600 * 1000,
|
||||
production: 600 * 1000, // 十分钟
|
||||
};
|
||||
const application = context.getApplication();
|
||||
|
|
|
|||
|
|
@ -22,13 +22,26 @@ async function createWechatLogin(params, context) {
|
|||
userId,
|
||||
});
|
||||
}
|
||||
await context.operate('wechatLogin', {
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
action: 'create',
|
||||
data: createData,
|
||||
}, {
|
||||
dontCollect: true,
|
||||
});
|
||||
if (type === 'login') {
|
||||
const closeRoot = context.openRootMode();
|
||||
await context.operate('wechatLogin', {
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
action: 'create',
|
||||
data: createData,
|
||||
}, {
|
||||
dontCollect: true,
|
||||
});
|
||||
closeRoot();
|
||||
}
|
||||
else {
|
||||
await context.operate('wechatLogin', {
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
action: 'create',
|
||||
data: createData,
|
||||
}, {
|
||||
dontCollect: true,
|
||||
});
|
||||
}
|
||||
return id;
|
||||
}
|
||||
exports.createWechatLogin = createWechatLogin;
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ const triggers = [
|
|||
case 'wechatPublic': {
|
||||
(0, assert_1.assert)(applicationType === 'wechatPublic' &&
|
||||
config.type === 'wechatPublic');
|
||||
if (process.env.OAK_PLATFORM === 'web') {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
Object.assign(updateData, {
|
||||
ticket: 'develop环境下无法真实获取二维码数据',
|
||||
url: `http://localhost:3000/wechatQrCode/scan?scene=${(0, uuid_1.shrinkUuidTo32Bytes)(id)}`,
|
||||
|
|
|
|||
|
|
@ -403,6 +403,12 @@ export type AspectDict<ED extends EntityDict> = {
|
|||
},
|
||||
context: BackendRuntimeContext<ED>
|
||||
) => Promise<void>;
|
||||
getApplicationPassports: (
|
||||
params: {
|
||||
applicationId: string;
|
||||
},
|
||||
context: BackendRuntimeContext<ED>
|
||||
) => Promise<EntityDict['applicationPassport']['Schema'][]>
|
||||
};
|
||||
|
||||
export default AspectDict;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
import { EntityDict } from "../oak-app-domain";
|
||||
import { BRC } from '../types/RuntimeCxt';
|
||||
|
||||
export async function getApplicationPassports<ED extends EntityDict>(
|
||||
params: {
|
||||
applicationId: string;
|
||||
},
|
||||
context: BRC<ED>
|
||||
) {
|
||||
const { applicationId } = params;
|
||||
const closeRoot = context.openRootMode();
|
||||
const applicationPassports = await context.select(
|
||||
'applicationPassport',
|
||||
{
|
||||
data: {
|
||||
id: 1,
|
||||
passportId: 1,
|
||||
passport: {
|
||||
id: 1,
|
||||
type: 1,
|
||||
config: 1,
|
||||
},
|
||||
isDefault: 1,
|
||||
},
|
||||
filter: {
|
||||
applicationId,
|
||||
}
|
||||
},
|
||||
{});
|
||||
closeRoot();
|
||||
|
||||
return applicationPassports;
|
||||
}
|
||||
|
|
@ -60,6 +60,7 @@ import {
|
|||
import {
|
||||
wechatMpJump,
|
||||
} from './wechatMpJump';
|
||||
import { getApplicationPassports } from './applicationPassport';
|
||||
|
||||
const aspectDict = {
|
||||
mergeUser,
|
||||
|
|
@ -116,7 +117,8 @@ const aspectDict = {
|
|||
syncToLocale,
|
||||
syncToWechat,
|
||||
wechatMpJump,
|
||||
syncSmsTemplate
|
||||
syncSmsTemplate,
|
||||
getApplicationPassports,
|
||||
};
|
||||
|
||||
export default aspectDict;
|
||||
|
|
|
|||
|
|
@ -1204,7 +1204,7 @@ async function loginFromWechatEnv<ED extends EntityDict>(
|
|||
undefined,
|
||||
wechatUser.user!
|
||||
);
|
||||
await updateWechatLogin({ successed: true });
|
||||
await updateWechatLogin({ userId: wechatUser.userId, successed: true });
|
||||
return tokenValue;
|
||||
} else {
|
||||
// 创建user和wechatUser(绑定并登录)
|
||||
|
|
|
|||
|
|
@ -30,12 +30,24 @@ export async function createWechatLogin<ED extends EntityDict>(
|
|||
userId,
|
||||
})
|
||||
}
|
||||
await context.operate('wechatLogin', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: createData as createWechatLoginData,
|
||||
}, {
|
||||
dontCollect: true,
|
||||
});
|
||||
if (type === 'login') {
|
||||
const closeRoot = context.openRootMode();
|
||||
await context.operate('wechatLogin', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: createData as createWechatLoginData,
|
||||
}, {
|
||||
dontCollect: true,
|
||||
});
|
||||
closeRoot();
|
||||
} else {
|
||||
await context.operate('wechatLogin', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
data: createData as createWechatLoginData,
|
||||
}, {
|
||||
dontCollect: true,
|
||||
});
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ export default OakComponent({
|
|||
id: wechatLoginId,
|
||||
},
|
||||
});
|
||||
const { successed, type } = wechatLogin;
|
||||
const { successed, type } = wechatLogin || {};
|
||||
this.setState(
|
||||
{
|
||||
successful: successed,
|
||||
|
|
|
|||
|
|
@ -148,10 +148,9 @@ const triggers: Trigger<EntityDict, 'wechatQrCode', BRC<EntityDict>>[] = [
|
|||
appId = self.id;
|
||||
if ((self!.config as WechatMpConfig).qrCodePrefix) {
|
||||
appType = 'wechatMpDomainUrl';
|
||||
url = `${
|
||||
(self!.config as WechatMpConfig)
|
||||
.qrCodePrefix
|
||||
}/${shrinkUuidTo32Bytes(id)}`;
|
||||
url = `${(self!.config as WechatMpConfig)
|
||||
.qrCodePrefix
|
||||
}/${shrinkUuidTo32Bytes(id)}`;
|
||||
} else {
|
||||
appType = 'wechatMpWxaCode';
|
||||
}
|
||||
|
|
@ -227,7 +226,7 @@ const triggers: Trigger<EntityDict, 'wechatQrCode', BRC<EntityDict>>[] = [
|
|||
applicationType === 'wechatPublic' &&
|
||||
config!.type === 'wechatPublic'
|
||||
);
|
||||
if (process.env.OAK_PLATFORM === 'web') {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
Object.assign(updateData, {
|
||||
ticket: 'develop环境下无法真实获取二维码数据',
|
||||
url: `http://localhost:3000/wechatQrCode/scan?scene=${shrinkUuidTo32Bytes(id)}`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue