diff --git a/packages/libs/lib-server/src/system/settings/service/models.ts b/packages/libs/lib-server/src/system/settings/service/models.ts
index e16ff77b..851c37d9 100644
--- a/packages/libs/lib-server/src/system/settings/service/models.ts
+++ b/packages/libs/lib-server/src/system/settings/service/models.ts
@@ -16,6 +16,7 @@ export class SysPublicSettings extends BaseSettings {
static __access__ = 'public';
registerEnabled = false;
+ userValidTimeEnabled?:boolean = false;
passwordLoginEnabled = true;
usernameRegisterEnabled = true;
mobileRegisterEnabled = false;
diff --git a/packages/ui/certd-client/src/components/index.ts b/packages/ui/certd-client/src/components/index.ts
index 008752a2..7f08df50 100644
--- a/packages/ui/certd-client/src/components/index.ts
+++ b/packages/ui/certd-client/src/components/index.ts
@@ -15,6 +15,7 @@ import PemInput from "./pem-input.vue";
import { defineAsyncComponent } from "vue";
import NotificationSelector from "../views/certd/notification/notification-selector/index.vue";
import EmailSelector from "./email-selector/index.vue";
+import ValidTimeFormat from "./valid-time-format.vue";
export default {
install(app: any) {
app.component(
@@ -27,6 +28,7 @@ export default {
app.component("TextEditable", TextEditable);
app.component("FileInput", FileInput);
app.component("PemInput", PemInput);
+ app.component("ValidTimeFormat", ValidTimeFormat);
// app.component("CodeEditor", CodeEditor);
app.component("CronLight", CronLight);
diff --git a/packages/ui/certd-client/src/components/valid-time-format.vue b/packages/ui/certd-client/src/components/valid-time-format.vue
new file mode 100644
index 00000000..2abfff72
--- /dev/null
+++ b/packages/ui/certd-client/src/components/valid-time-format.vue
@@ -0,0 +1,32 @@
+
+
+
+
+
diff --git a/packages/ui/certd-client/src/store/settings/api.basic.ts b/packages/ui/certd-client/src/store/settings/api.basic.ts
index b53a6409..d7a32866 100644
--- a/packages/ui/certd-client/src/store/settings/api.basic.ts
+++ b/packages/ui/certd-client/src/store/settings/api.basic.ts
@@ -30,6 +30,7 @@ export type PlusInfo = {
};
export type SysPublicSetting = {
registerEnabled?: boolean;
+ userValidTimeEnabled?: boolean;
usernameRegisterEnabled?: boolean;
mobileRegisterEnabled?: boolean;
emailRegisterEnabled?: boolean;
diff --git a/packages/ui/certd-client/src/store/user/api.user.ts b/packages/ui/certd-client/src/store/user/api.user.ts
index 9e81b51b..bfd61d41 100644
--- a/packages/ui/certd-client/src/store/user/api.user.ts
+++ b/packages/ui/certd-client/src/store/user/api.user.ts
@@ -27,6 +27,8 @@ export interface UserInfoRes {
avatar?: string;
roleIds: number[];
isWeak?: boolean;
+ validTime?: number;
+ status?: number;
}
export interface LoginRes {
diff --git a/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue b/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue
index a542d407..d5a5e511 100644
--- a/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue
+++ b/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue
@@ -35,6 +35,10 @@
+
+
+
+
diff --git a/packages/ui/certd-client/src/views/sys/authority/user/crud.tsx b/packages/ui/certd-client/src/views/sys/authority/user/crud.tsx
index 7e8d23c2..25ff879d 100644
--- a/packages/ui/certd-client/src/views/sys/authority/user/crud.tsx
+++ b/packages/ui/certd-client/src/views/sys/authority/user/crud.tsx
@@ -3,6 +3,7 @@ import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq,
import { useUserStore } from "/@/store/user";
import { Modal, notification } from "ant-design-vue";
import dayjs from "dayjs";
+import { useSettingStore } from "/@/store/settings";
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const pageRequest = async (query: UserPageQuery): Promise => {
@@ -22,6 +23,10 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
const userStore = useUserStore();
+ const settingStore = useSettingStore();
+ const userValidTimeEnabled = compute(() => {
+ return settingStore.sysPublic.userValidTimeEnabled === true;
+ });
return {
crudOptions: {
request: {
@@ -213,20 +218,28 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
},
validTime: {
title: "有效期",
- type: ["date", "time-humanize"],
+ type: "date",
+ form: {
+ show: userValidTimeEnabled,
+ },
column: {
align: "center",
sorter: true,
width: 100,
- component: {
- title: compute(({ row }) => {
- return dayjs(row.validTime).format("YYYY-MM-DD");
- }),
- useFormatGreater: 30000000000,
- options: {
- largest: 1,
- units: ["y", "d", "h"],
- },
+ show: userValidTimeEnabled,
+ cellRender({ value }) {
+ if (value == null || value === 0) {
+ return "";
+ }
+ if (value < dayjs().valueOf()) {
+ return 已过期;
+ }
+ const date = dayjs(value).format("YYYY-MM-DD");
+ return (
+
+
+
+ );
},
},
valueBuilder({ value, row, key }) {
diff --git a/packages/ui/certd-client/src/views/sys/settings/tabs/register.vue b/packages/ui/certd-client/src/views/sys/settings/tabs/register.vue
index eb9ccec3..8f395eaa 100644
--- a/packages/ui/certd-client/src/views/sys/settings/tabs/register.vue
+++ b/packages/ui/certd-client/src/views/sys/settings/tabs/register.vue
@@ -11,6 +11,13 @@
+
+
+ 有效期内用户可正常使用,失效后流水线将被停用
+
@@ -154,6 +161,14 @@ async function loadSysSettings() {
if (data?.private.sms?.type) {
await loadTypeDefine(data.private.sms.type);
}
+ if (!settingsStore.isPlus) {
+ formState.public.userValidTimeEnabled = false;
+ formState.public.emailRegisterEnabled = false;
+ }
+
+ if (!settingsStore.isComm) {
+ formState.public.smsLoginEnabled = false;
+ }
}
const saveLoading = ref(false);
diff --git a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts
index 0f8f4c79..3899204c 100644
--- a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts
+++ b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts
@@ -329,6 +329,7 @@ export class PipelineService extends BaseService {
if (isComm()) {
await this.checkHasDeployCount(id, entity.userId);
}
+ await this.checkUserStatus(entity.userId)
this.cron.register({
name: `pipeline.${id}.trigger.once`,
cron: null,
@@ -446,6 +447,13 @@ export class PipelineService extends BaseService {
if (isComm()) {
suite = await this.checkHasDeployCount(id, entity.userId);
}
+ try{
+ await this.checkUserStatus(entity.userId)
+ }catch (e) {
+ logger.info(e.message)
+ return
+ }
+
const pipeline = JSON.parse(entity.content);
if (!pipeline.id) {
@@ -745,5 +753,25 @@ export class PipelineService extends BaseService {
}
-
+ private async checkUserStatus(userId: number) {
+ const userEntity = await this.userService.info(userId);
+ if(userEntity == null){
+ throw new Error('用户不存在');
+ }
+ if(userEntity.status === 0){
+ const message = `账户${userId}已被禁用,禁止运行流水线`
+ throw new Error(message)
+ }
+ const sysPublic = await this.sysSettingsService.getPublicSettings()
+ if(isPlus() && sysPublic.userValidTimeEnabled === true){
+ //校验用户有效期是否设置
+ if(userEntity.validTime!= null && userEntity.validTime > 0){
+ if(userEntity.validTime < new Date().getTime()){
+ //用户已过期
+ const message = `账户${userId}已过有效期,禁止运行流水线`
+ throw new Error(message)
+ }
+ }
+ }
+ }
}