@simitgroup/simpleapp-generator 2.0.1-g-alpha → 2.0.1-i-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReleaseNote.md +8 -0
- package/package.json +1 -1
- package/templates/nest/src/simple-app/_core/features/auth/api-key/validators/static-api-key.validator.ts.eta +1 -1
- package/templates/nest/src/simple-app/_core/features/mini-app/developer-portal/developer-portal-env-development.service.ts.eta +1 -1
- package/templates/nest/src/simple-app/_core/features/profile/profile.schema.ts.eta +3 -1
- package/templates/nest/src/simple-app/_core/features/user-context/robot-user.service.ts.eta +2 -2
- package/templates/nest/src/simple-app/_core/features/user-context/user.context.ts.eta +20 -1
package/ReleaseNote.md
CHANGED
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ export class StaticApiKeyValidator implements IApiKeyValidator {
|
|
|
17
17
|
const xOrg = req.get(HEADER_X_ORG) ?? Base64URL.encodeText('0-0-0');
|
|
18
18
|
const guestAccessToken = req.get(HEADER_X_GUESS_ACCESS_TOKEN);
|
|
19
19
|
|
|
20
|
-
user.setAsStaticUser('00000000-0000-0000-0000-000000000000', 'robot', 'Robot', 'robot@a.org', xOrg);
|
|
20
|
+
await user.setAsStaticUser('00000000-0000-0000-0000-000000000000', 'robot', 'Robot', 'robot@a.org', xOrg);
|
|
21
21
|
user.setUserType('robot');
|
|
22
22
|
|
|
23
23
|
if (guestAccessToken) {
|
|
@@ -36,7 +36,7 @@ export class DeveloperPortalEnvDevelopmentService {
|
|
|
36
36
|
|
|
37
37
|
async publish(appUser: UserContext, developerPortalAppId: string, dto: MiniApp) {
|
|
38
38
|
this.assertDemoCompanyDefined();
|
|
39
|
-
appUser.setAsStaticUser(dto.author.uid, dto.author.email, dto.author.name, dto.author.email, process.env.DEMO_COMPANY_XORG);
|
|
39
|
+
await appUser.setAsStaticUser(dto.author.uid, dto.author.email, dto.author.name, dto.author.email, process.env.DEMO_COMPANY_XORG);
|
|
40
40
|
appUser.setLicense(TenantLicenseEnum.ENTERPRISE); // else cannot install mini app
|
|
41
41
|
|
|
42
42
|
const miniApp = await this.findMiniApp(developerPortalAppId, MiniAppManagerEnvEnum.DEV);
|
|
@@ -5,7 +5,7 @@ import { Permission } from 'src/simple-app/_core/resources/permission/permission
|
|
|
5
5
|
import { Role } from '../auth/role-guard/roles.enum';
|
|
6
6
|
import { Organization } from '../../resources/organization/organization.schema';
|
|
7
7
|
import { Tenant } from '../../resources/tenant/tenant.schema';
|
|
8
|
-
export {KeyValue} from '../../framework/schemas';
|
|
8
|
+
export { KeyValue } from '../../framework/schemas';
|
|
9
9
|
export class UserContextInfo {
|
|
10
10
|
@ApiProperty({ type: String })
|
|
11
11
|
_id: string;
|
|
@@ -106,6 +106,8 @@ export class ProfileUserBranch {
|
|
|
106
106
|
orgRecordId: String;
|
|
107
107
|
@ApiProperty({ type: String })
|
|
108
108
|
xOrg: String;
|
|
109
|
+
@ApiProperty({ type: Object, required: false })
|
|
110
|
+
organization?: any;
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
export class TenantPermission {
|
|
@@ -99,7 +99,7 @@ export class SimpleAppRobotUserService {
|
|
|
99
99
|
const user = userContext;
|
|
100
100
|
const xorg = appUser.generateXOrg(user.tenantId, user.orgId, user.branchId);
|
|
101
101
|
|
|
102
|
-
appUser.setAsStaticUser(user.uid ?? '00000000-0000-0000-0000-000000000000', user.uname ?? 'robot', user.fullName ?? 'Robot', user.email ?? 'robot@a.org', xorg);
|
|
102
|
+
await appUser.setAsStaticUser(user.uid ?? '00000000-0000-0000-0000-000000000000', user.uname ?? 'robot', user.fullName ?? 'Robot', user.email ?? 'robot@a.org', xorg);
|
|
103
103
|
appUser.setTimeZone(user.timeZone ?? this.defaultTimeZone);
|
|
104
104
|
appUser.setCountry(user.country ?? this.defaultCountry);
|
|
105
105
|
appUser.setCurrency(user.currency ?? this.defaultCurrency);
|
|
@@ -111,7 +111,7 @@ export class SimpleAppRobotUserService {
|
|
|
111
111
|
// console.log('prepareAppUserprepareAppUser');
|
|
112
112
|
// this.appmodel,
|
|
113
113
|
const appuser = new UserContext(this.userModel, this.permModel, this.miniAppInstallationModel,envs[0]);
|
|
114
|
-
appuser.setAsStaticUser('00000000-0000-0000-0000-000000000000', 'robot', 'Robot', 'robot@a.org', Base64URL.encodeText('0-0-0'));
|
|
114
|
+
await appuser.setAsStaticUser('00000000-0000-0000-0000-000000000000', 'robot', 'Robot', 'robot@a.org', Base64URL.encodeText('0-0-0'));
|
|
115
115
|
|
|
116
116
|
const tenantId = data?.tenantId ?? 0;
|
|
117
117
|
const orgId = data?.orgId ?? 0;
|
|
@@ -885,6 +885,7 @@ export class UserContext extends UserContextInfo {
|
|
|
885
885
|
_id: '$org._id',
|
|
886
886
|
code: '$org.orgCode',
|
|
887
887
|
label: '$org.orgName',
|
|
888
|
+
imageUrl: '$org.imageUrl',
|
|
888
889
|
},
|
|
889
890
|
},
|
|
890
891
|
},
|
|
@@ -925,6 +926,7 @@ export class UserContext extends UserContextInfo {
|
|
|
925
926
|
groups: p.groups,
|
|
926
927
|
branch: p.branch,
|
|
927
928
|
orgRecordId: p.organization._id,
|
|
929
|
+
organization: p.organization,
|
|
928
930
|
xOrg: this.generateXOrg(p.tenantId, p.orgId, p.branchId),
|
|
929
931
|
});
|
|
930
932
|
}
|
|
@@ -974,7 +976,7 @@ export class UserContext extends UserContextInfo {
|
|
|
974
976
|
return results;
|
|
975
977
|
}
|
|
976
978
|
|
|
977
|
-
setAsStaticUser = (uid: string, uname: string, name: string, email: string, xorg: string) => {
|
|
979
|
+
setAsStaticUser = async (uid: string, uname: string, name: string, email: string, xorg: string) => {
|
|
978
980
|
// Define token info
|
|
979
981
|
this.token = '';
|
|
980
982
|
this.uid = uid;
|
|
@@ -984,6 +986,23 @@ export class UserContext extends UserContextInfo {
|
|
|
984
986
|
this.ssoACL = {};
|
|
985
987
|
this.roles = [Role.Everyone, Role.User, Role.SuperUser];
|
|
986
988
|
this.setXOrg(xorg);
|
|
989
|
+
const pipeLine:PipelineStage[] = [
|
|
990
|
+
{$match:{ tenantId : -1 }},
|
|
991
|
+
{$unionWith: { coll: "organization", pipeline: [ {$match:{orgId: this.orgId}}] } },
|
|
992
|
+
{$limit:1}
|
|
993
|
+
]
|
|
994
|
+
|
|
995
|
+
// console.log("set as static user", pipeLine)
|
|
996
|
+
const result:Organization[] = await this.userModel.aggregate(pipeLine).exec();
|
|
997
|
+
// console.log("result",result)
|
|
998
|
+
if(result && result.length>0){
|
|
999
|
+
const res = result[0]
|
|
1000
|
+
this.currency = res.currency
|
|
1001
|
+
this.country = res.country
|
|
1002
|
+
this.timeZone = res.timeZone
|
|
1003
|
+
this.offsetMinute = res.offsetMinute
|
|
1004
|
+
}
|
|
1005
|
+
|
|
987
1006
|
};
|
|
988
1007
|
|
|
989
1008
|
setGuestToken(tokenStr: string) {
|