This is an automated email from the ASF dual-hosted git repository.
lgcareer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 68e3487 feature: Add user state #1923 (#2424)
68e3487 is described below
commit 68e3487e348737bdeed71bdeea53eff6e3aaf8c9
Author: Rubik-W <[email protected]>
AuthorDate: Mon May 11 11:45:29 2020 +0800
feature: Add user state #1923 (#2424)
* feature: #1923
* fix:docker sql script add column
* fix: update sql script
* fix: UT bug
* fix: UT bug
* fix: UT bug
* fix: e2e UT bug
* fix: e2e button location
Co-authored-by: dailidong <[email protected]>
---
docker/postgres/docker-entrypoint-initdb/init.sql | 3 ++-
.../api/controller/UsersController.java | 25 ++++++++++++----------
.../apache/dolphinscheduler/api/enums/Status.java | 1 +
.../api/interceptor/LoginHandlerInterceptor.java | 10 +++++++++
.../api/security/PasswordAuthenticator.java | 8 +++++++
.../dolphinscheduler/api/service/UsersService.java | 14 ++++++++----
.../api/controller/LoginControllerTest.java | 1 -
.../interceptor/LoginHandlerInterceptorTest.java | 6 ++++++
.../api/security/PasswordAuthenticatorTest.java | 8 +++++++
.../api/service/UsersServiceTest.java | 18 +++++++++-------
.../apache/dolphinscheduler/dao/entity/User.java | 14 ++++++++++++
.../dolphinscheduler/dao/mapper/UserMapper.xml | 2 +-
.../security/pages/users/_source/createUser.vue | 15 ++++++++++++-
.../pages/security/pages/users/_source/list.vue | 12 ++++++++---
.../src/js/module/i18n/locale/en_US.js | 4 +++-
.../src/js/module/i18n/locale/zh_CN.js | 4 +++-
.../locator/security/UserManageLocator.java | 2 +-
.../1.2.2_schema/mysql/dolphinscheduler_ddl.sql | 21 ++++++++++++++++++
.../postgresql/dolphinscheduler_ddl.sql | 20 +++++++++++++++++
19 files changed, 155 insertions(+), 33 deletions(-)
diff --git a/docker/postgres/docker-entrypoint-initdb/init.sql
b/docker/postgres/docker-entrypoint-initdb/init.sql
index b26520e..0251504 100755
--- a/docker/postgres/docker-entrypoint-initdb/init.sql
+++ b/docker/postgres/docker-entrypoint-initdb/init.sql
@@ -623,6 +623,7 @@ CREATE TABLE t_ds_user (
create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL ,
queue varchar(64) DEFAULT NULL ,
+ state int DEFAULT 1 ,
PRIMARY KEY (id)
);
@@ -749,7 +750,7 @@ ALTER TABLE t_ds_worker_server ALTER COLUMN id SET DEFAULT
NEXTVAL('t_ds_worker_
-- Records of t_ds_user?user : admin , password : dolphinscheduler123
-INSERT INTO
t_ds_user(user_name,user_password,user_type,email,phone,tenant_id,create_time,update_time)
VALUES ('admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', '[email protected]', 'xx',
'0', '2018-03-27 15:48:50', '2018-10-24 17:40:22');
+INSERT INTO
t_ds_user(user_name,user_password,user_type,email,phone,state,tenant_id,create_time,update_time)
VALUES ('admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', '[email protected]', 'xx',
1, '0', '2018-03-27 15:48:50', '2018-10-24 17:40:22');
-- Records of t_ds_alertgroup,dolphinscheduler warning group
INSERT INTO
t_ds_alertgroup(group_name,group_type,description,create_time,update_time)
VALUES ('dolphinscheduler warning group', '0', 'dolphinscheduler warning
group','2018-11-29 10:20:39', '2018-11-29 10:20:39');
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
index 08d862e..456d8c2 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/UsersController.java
@@ -72,7 +72,8 @@ public class UsersController extends BaseController {
@ApiImplicitParam(name = "tenantId", value = "TENANT_ID", dataType
= "Int", example = "100"),
@ApiImplicitParam(name = "queue", value = "QUEUE", dataType =
"Int", example = "100"),
@ApiImplicitParam(name = "email", value = "EMAIL", dataType =
"Int", example = "100"),
- @ApiImplicitParam(name = "phone", value = "PHONE", dataType =
"Int", example = "100")
+ @ApiImplicitParam(name = "phone", value = "PHONE", dataType =
"Int", example = "100"),
+ @ApiImplicitParam(name = "state", value = "STATE", dataType =
"Int", example = "1")
})
@PostMapping(value = "/create")
@ResponseStatus(HttpStatus.CREATED)
@@ -83,11 +84,11 @@ public class UsersController extends BaseController {
@RequestParam(value = "tenantId") int tenantId,
@RequestParam(value = "queue", required = false,
defaultValue = "") String queue,
@RequestParam(value = "email") String email,
- @RequestParam(value = "phone", required = false)
String phone) throws Exception {
- logger.info("login user {}, create user, userName: {}, email: {},
tenantId: {}, userPassword: {}, phone: {}, user queue: {}",
- loginUser.getUserName(), userName, email, tenantId,
Constants.PASSWORD_DEFAULT, phone, queue);
-
- Map<String, Object> result = usersService.createUser(loginUser,
userName, userPassword, email, tenantId, phone, queue);
+ @RequestParam(value = "phone", required = false)
String phone,
+ @RequestParam(value = "state", required = false)
int state) throws Exception {
+ logger.info("login user {}, create user, userName: {}, email: {},
tenantId: {}, userPassword: {}, phone: {}, user queue: {}, state: {}",
+ loginUser.getUserName(), userName, email, tenantId,
Constants.PASSWORD_DEFAULT, phone, queue, state);
+ Map<String, Object> result = usersService.createUser(loginUser,
userName, userPassword, email, tenantId, phone, queue, state);
return returnDataList(result);
}
@@ -146,7 +147,8 @@ public class UsersController extends BaseController {
@ApiImplicitParam(name = "tenantId", value = "TENANT_ID", dataType
= "Int", example = "100"),
@ApiImplicitParam(name = "queue", value = "QUEUE", dataType =
"Int", example = "100"),
@ApiImplicitParam(name = "email", value = "EMAIL", dataType =
"Int", example = "100"),
- @ApiImplicitParam(name = "phone", value = "PHONE", dataType =
"Int", example = "100")
+ @ApiImplicitParam(name = "phone", value = "PHONE", dataType =
"Int", example = "100"),
+ @ApiImplicitParam(name = "state", value = "STATE", dataType =
"Int", example = "1")
})
@PostMapping(value = "/update")
@ResponseStatus(HttpStatus.OK)
@@ -158,10 +160,11 @@ public class UsersController extends BaseController {
@RequestParam(value = "queue", required = false,
defaultValue = "") String queue,
@RequestParam(value = "email") String email,
@RequestParam(value = "tenantId") int tenantId,
- @RequestParam(value = "phone", required = false)
String phone) throws Exception {
- logger.info("login user {}, updateProcessInstance user, userName: {},
email: {}, tenantId: {}, userPassword: {}, phone: {}, user queue: {}",
- loginUser.getUserName(), userName, email, tenantId,
Constants.PASSWORD_DEFAULT, phone, queue);
- Map<String, Object> result = usersService.updateUser(id, userName,
userPassword, email, tenantId, phone, queue);
+ @RequestParam(value = "phone", required = false)
String phone,
+ @RequestParam(value = "state", required = false)
int state) throws Exception {
+ logger.info("login user {}, updateProcessInstance user, userName: {},
email: {}, tenantId: {}, userPassword: {}, phone: {}, user queue: {}, state:
{}",
+ loginUser.getUserName(), userName, email, tenantId,
Constants.PASSWORD_DEFAULT, phone, queue, state);
+ Map<String, Object> result = usersService.updateUser(id, userName,
userPassword, email, tenantId, phone, queue, state);
return returnDataList(result);
}
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
index b3d10da..ae7300f 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
@@ -175,6 +175,7 @@ public enum Status {
QUERY_WORKER_GROUP_FAIL(10146,"query worker group fail ", "查询worker分组失败"),
DELETE_WORKER_GROUP_FAIL(10147,"delete worker group fail ",
"删除worker分组失败"),
COPY_PROCESS_DEFINITION_ERROR(10148,"copy process definition error",
"复制工作流错误"),
+ USER_DISABLED(10149,"The current user is disabled", "当前用户已停用"),
UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found", "UDF函数不存在"),
UDF_FUNCTION_EXISTS(20002, "UDF function already exists", "UDF函数已存在"),
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java
index 98bac42..af29cb6 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java
@@ -16,9 +16,11 @@
*/
package org.apache.dolphinscheduler.api.interceptor;
+import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.security.Authenticator;
import org.apache.dolphinscheduler.api.service.SessionService;
import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.commons.httpclient.HttpStatus;
@@ -85,6 +87,14 @@ public class LoginHandlerInterceptor implements
HandlerInterceptor {
return false;
}
}
+
+ // check user state
+ if (user.getState() == Flag.NO.ordinal()) {
+ response.setStatus(HttpStatus.SC_UNAUTHORIZED);
+ logger.info(Status.USER_DISABLED.getMsg());
+ return false;
+ }
+
request.setAttribute(Constants.SESSION_USER, user);
return true;
}
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/security/PasswordAuthenticator.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/security/PasswordAuthenticator.java
index a9e287b..69930fc 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/security/PasswordAuthenticator.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/security/PasswordAuthenticator.java
@@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.api.service.SessionService;
import org.apache.dolphinscheduler.api.service.UsersService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.dao.entity.Session;
import org.apache.dolphinscheduler.dao.entity.User;
import org.slf4j.Logger;
@@ -49,6 +50,13 @@ public class PasswordAuthenticator implements Authenticator {
return result;
}
+ // check user state
+ if (user.getState() == Flag.NO.ordinal()) {
+ result.setCode(Status.USER_DISABLED.getCode());
+ result.setMsg(Status.USER_DISABLED.getMsg());
+ return result;
+ }
+
// create session
String sessionId = sessionService.createSession(user, extra);
if (sessionId == null) {
diff --git
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
index 220b4fc..bb31733 100644
---
a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
+++
b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
@@ -94,7 +94,8 @@ public class UsersService extends BaseService {
String email,
int tenantId,
String phone,
- String queue) throws Exception {
+ String queue,
+ int state) throws Exception {
Map<String, Object> result = new HashMap<>(5);
@@ -115,7 +116,7 @@ public class UsersService extends BaseService {
return result;
}
- User user = createUser(userName, userPassword, email, tenantId, phone,
queue);
+ User user = createUser(userName, userPassword, email, tenantId, phone,
queue, state);
Tenant tenant = tenantMapper.queryById(tenantId);
// resource upload startup
@@ -139,7 +140,8 @@ public class UsersService extends BaseService {
String email,
int tenantId,
String phone,
- String queue) throws Exception {
+ String queue,
+ int state) throws Exception {
User user = new User();
Date now = new Date();
@@ -148,6 +150,7 @@ public class UsersService extends BaseService {
user.setEmail(email);
user.setTenantId(tenantId);
user.setPhone(phone);
+ user.setState(state);
// create general users, administrator users are currently built-in
user.setUserType(UserType.GENERAL_USER);
user.setCreateTime(now);
@@ -260,7 +263,8 @@ public class UsersService extends BaseService {
String email,
int tenantId,
String phone,
- String queue) throws Exception {
+ String queue,
+ int state) throws Exception {
Map<String, Object> result = new HashMap<>(5);
result.put(Constants.STATUS, false);
@@ -309,7 +313,9 @@ public class UsersService extends BaseService {
}
user.setPhone(phone);
}
+
user.setQueue(queue);
+ user.setState(state);
Date now = new Date();
user.setUpdateTime(now);
diff --git
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/LoginControllerTest.java
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/LoginControllerTest.java
index 5be7b07..a4ecd29 100644
---
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/LoginControllerTest.java
+++
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/LoginControllerTest.java
@@ -56,7 +56,6 @@ public class LoginControllerTest extends
AbstractControllerTest{
logger.info(mvcResult.getResponse().getContentAsString());
}
-
@Test
public void testSignOut() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
diff --git
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptorTest.java
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptorTest.java
index b8a002a..d25a3ef 100644
---
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptorTest.java
+++
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptorTest.java
@@ -57,6 +57,7 @@ public class LoginHandlerInterceptorTest {
User mockUser = new User();
mockUser.setId(1);
mockUser.setUserType(UserType.GENERAL_USER);
+ mockUser.setState(1);
// test no token
when(authenticator.getAuthUser(request)).thenReturn(mockUser);
@@ -67,5 +68,10 @@ public class LoginHandlerInterceptorTest {
when(request.getHeader("token")).thenReturn(token);
when(userMapper.queryUserByToken(token)).thenReturn(mockUser);
Assert.assertTrue(interceptor.preHandle(request, response, null));
+
+ // test disable user
+ mockUser.setState(0);
+ when(authenticator.getAuthUser(request)).thenReturn(mockUser);
+ Assert.assertFalse(interceptor.preHandle(request, response, null));
}
}
diff --git
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/PasswordAuthenticatorTest.java
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/PasswordAuthenticatorTest.java
index cccc307..dca70f8 100644
---
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/PasswordAuthenticatorTest.java
+++
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/security/PasswordAuthenticatorTest.java
@@ -67,6 +67,7 @@ public class PasswordAuthenticatorTest {
mockUser.setEmail("[email protected]");
mockUser.setUserPassword("test");
mockUser.setId(1);
+ mockUser.setState(1);
mockSession = new Session();
mockSession.setId(UUID.randomUUID().toString());
@@ -82,6 +83,13 @@ public class PasswordAuthenticatorTest {
Result result = authenticator.authenticate("test", "test",
"127.0.0.1");
Assert.assertEquals(Status.SUCCESS.getCode(), (int) result.getCode());
logger.info(result.toString());
+
+ mockUser.setState(0);
+ when(usersService.queryUser("test", "test")).thenReturn(mockUser);
+ when(sessionService.createSession(mockUser,
"127.0.0.1")).thenReturn(mockSession.getId());
+ Result result1 = authenticator.authenticate("test", "test",
"127.0.0.1");
+ Assert.assertEquals(Status.USER_DISABLED.getCode(), (int)
result1.getCode());
+ logger.info(result1.toString());
}
@Test
diff --git
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
index 58ee6fd..4c857cb 100644
---
a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
+++
b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
@@ -98,41 +98,42 @@ public class UsersServiceTest {
String email = "[email protected]";
int tenantId = Integer.MAX_VALUE;
String phone= "13456432345";
+ int state = 1;
try {
//userName error
- Map<String, Object> result = usersService.createUser(user,
userName, userPassword, email, tenantId, phone, queueName);
+ Map<String, Object> result = usersService.createUser(user,
userName, userPassword, email, tenantId, phone, queueName, state);
logger.info(result.toString());
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR,
result.get(Constants.STATUS));
userName = "userTest0001";
userPassword = "userTest000111111111111111";
//password error
- result = usersService.createUser(user, userName, userPassword,
email, tenantId, phone, queueName);
+ result = usersService.createUser(user, userName, userPassword,
email, tenantId, phone, queueName, state);
logger.info(result.toString());
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR,
result.get(Constants.STATUS));
userPassword = "userTest0001";
email = "1q.com";
//email error
- result = usersService.createUser(user, userName, userPassword,
email, tenantId, phone, queueName);
+ result = usersService.createUser(user, userName, userPassword,
email, tenantId, phone, queueName, state);
logger.info(result.toString());
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR,
result.get(Constants.STATUS));
email = "[email protected]";
phone ="2233";
//phone error
- result = usersService.createUser(user, userName, userPassword,
email, tenantId, phone, queueName);
+ result = usersService.createUser(user, userName, userPassword,
email, tenantId, phone, queueName, state);
logger.info(result.toString());
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR,
result.get(Constants.STATUS));
phone = "13456432345";
//tenantId not exists
- result = usersService.createUser(user, userName, userPassword,
email, tenantId, phone, queueName);
+ result = usersService.createUser(user, userName, userPassword,
email, tenantId, phone, queueName, state);
logger.info(result.toString());
Assert.assertEquals(Status.TENANT_NOT_EXIST,
result.get(Constants.STATUS));
//success
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
- result = usersService.createUser(user, userName, userPassword,
email, 1, phone, queueName);
+ result = usersService.createUser(user, userName, userPassword,
email, 1, phone, queueName, state);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
@@ -225,13 +226,13 @@ public class UsersServiceTest {
String userPassword = "userTest0001";
try {
//user not exist
- Map<String, Object> result =
usersService.updateUser(0,userName,userPassword,"[email protected]",1,"13457864543","queue");
+ Map<String, Object> result =
usersService.updateUser(0,userName,userPassword,"[email protected]",1,"13457864543","queue",
1);
Assert.assertEquals(Status.USER_NOT_EXIST,
result.get(Constants.STATUS));
logger.info(result.toString());
//success
when(userMapper.selectById(1)).thenReturn(getUser());
- result =
usersService.updateUser(1,userName,userPassword,"[email protected]",1,"13457864543","queue");
+ result =
usersService.updateUser(1,userName,userPassword,"[email protected]",1,"13457864543","queue",
1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} catch (Exception e) {
@@ -482,6 +483,7 @@ public class UsersServiceTest {
user.setUserType(UserType.ADMIN_USER);
user.setUserName("userTest0001");
user.setUserPassword("userTest0001");
+ user.setState(1);
return user;
}
diff --git
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java
index 8849be0..b4f2f93 100644
---
a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java
+++
b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/User.java
@@ -68,6 +68,11 @@ public class User {
private int tenantId;
/**
+ * user state
+ */
+ private int state;
+
+ /**
* tenant code
*/
@TableField(exist = false)
@@ -219,6 +224,14 @@ public class User {
this.queue = queue;
}
+ public int getState() {
+ return state;
+ }
+
+ public void setState(int state) {
+ this.state = state;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -254,6 +267,7 @@ public class User {
", phone='" + phone + '\'' +
", userType=" + userType +
", tenantId=" + tenantId +
+ ", state=" + state +
", tenantCode='" + tenantCode + '\'' +
", tenantName='" + tenantName + '\'' +
", queueName='" + queueName + '\'' +
diff --git
a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UserMapper.xml
b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UserMapper.xml
index fcf8a13..9ad2567 100644
---
a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UserMapper.xml
+++
b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UserMapper.xml
@@ -32,7 +32,7 @@
</select>
<select id="queryUserPaging"
resultType="org.apache.dolphinscheduler.dao.entity.User">
select
u.id,u.user_name,u.user_password,u.user_type,u.email,u.phone,u.tenant_id,u.create_time,
- u.update_time,t.tenant_name,
+ u.update_time,t.tenant_name,u.state,
case when u.queue <![CDATA[ <> ]]> '' then u.queue else q.queue_name
end as queue, q.queue_name
from t_ds_user u
left join t_ds_tenant t on u.tenant_id=t.id
diff --git
a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/createUser.vue
b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/createUser.vue
index 866fb4e..a51ec24 100644
---
a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/createUser.vue
+++
b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/createUser.vue
@@ -93,6 +93,15 @@
</x-input>
</template>
</m-list-box-f>
+ <m-list-box-f>
+ <template slot="name">{{$t('State')}}</template>
+ <template slot="content">
+ <x-radio-group v-model="userState" >
+ <x-radio :label="'1'">{{$t('Enable')}}</x-radio>
+ <x-radio :label="'0'">{{$t('Disable')}}</x-radio>
+ </x-radio-group>
+ </template>
+ </m-list-box-f>
</div>
</template>
</m-popup>
@@ -118,6 +127,7 @@
queueName: '',
email: '',
phone: '',
+ userState: '1',
tenantList: [],
// Source admin user information
isADMIN: store.state.user.userInfo.userType === 'ADMIN_USER' &&
router.history.current.name !== 'account'
@@ -241,7 +251,8 @@
tenantId: this.tenantId,
email: this.email,
queue: queueCode,
- phone: this.phone
+ phone: this.phone,
+ state: this.userState
}
if (this.item) {
@@ -270,6 +281,7 @@
this.userPassword = ''
this.email = this.item.email
this.phone = this.item.phone
+ this.userState = this.item.state + '' || '1'
this.tenantId = this.item.tenantId
this.$nextTick(() => {
this.queueName = _.find(this.queueList, ['code',
this.item.queue]).id||''
@@ -282,6 +294,7 @@
this.userPassword = ''
this.email = this.item.email
this.phone = this.item.phone
+ this.userState = this.state + '' || '1'
this.tenantId = this.item.tenantId
if(this.queueList.length>0) {
this.queueName = _.find(this.queueList, ['code',
this.item.queue]).id
diff --git
a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/list.vue
b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/list.vue
index ead385c..cb4a78f 100644
---
a/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/list.vue
+++
b/dolphinscheduler-ui/src/js/conf/home/pages/security/pages/users/_source/list.vue
@@ -40,7 +40,9 @@
<th>
<span>{{$t('Phone')}}</span>
</th>
-
+ <th id="state">
+ <span>{{$t('State')}}</span>
+ </th>
<th>
<span>{{$t('Create Time')}}</span>
</th>
@@ -72,6 +74,10 @@
<span>{{item.phone || '-'}}</span>
</td>
<td>
+ <span v-if="item.state == 1">{{$t('Enable')}}</span>
+ <span v-else>{{$t('Disable')}}</span>
+ </td>
+ <td>
<span v-if="item.createTime">{{item.createTime |
formatDate}}</span>
<span v-else>-</span>
</td>
@@ -232,7 +238,7 @@
getLeaf(data)
return result
},
- _authFile (item, i) {
+ _authFile (item, i) {
this.$refs[`poptip-auth-${i}`][0].doClose()
this.getResourceList({
id: item.id,
@@ -257,7 +263,7 @@
})
let fileTargetList = []
let udfTargetList = []
-
+
let pathId = []
data[1].forEach(v=>{
let arr = []
diff --git a/dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js
b/dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js
index 37aa244..026b96b 100755
--- a/dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js
+++ b/dolphinscheduler-ui/src/js/module/i18n/locale/en_US.js
@@ -590,5 +590,7 @@ export default {
'Cannot select the same node for successful branch flow and failed branch
flow': 'Cannot select the same node for successful branch flow and failed
branch flow',
'Successful branch flow and failed branch flow are required': 'Successful
branch flow and failed branch flow are required',
'Unauthorized or deleted resources': 'Unauthorized or deleted resources',
- 'Please delete all non-existent resources': 'Please delete all non-existent
resources'
+ 'Please delete all non-existent resources': 'Please delete all non-existent
resources',
+ 'Enable': 'Enable',
+ 'Disable': 'Disable'
}
diff --git a/dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js
b/dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js
index ad9ac10..39f237c 100755
--- a/dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js
+++ b/dolphinscheduler-ui/src/js/module/i18n/locale/zh_CN.js
@@ -590,5 +590,7 @@ export default {
'Cannot select the same node for successful branch flow and failed branch
flow': '成功分支流转和失败分支流转不能选择同一个节点',
'Successful branch flow and failed branch flow are required':
'成功分支流转和失败分支流转必填',
'Unauthorized or deleted resources': '未授权或已删除资源',
- 'Please delete all non-existent resources': '请删除所有未授权或已删除资源'
+ 'Please delete all non-existent resources': '请删除所有未授权或已删除资源',
+ 'Enable': '启用',
+ 'Disable': '停用'
}
diff --git
a/e2e/src/test/java/org/apache/dolphinscheduler/locator/security/UserManageLocator.java
b/e2e/src/test/java/org/apache/dolphinscheduler/locator/security/UserManageLocator.java
index b5ecccc..9f685f0 100644
---
a/e2e/src/test/java/org/apache/dolphinscheduler/locator/security/UserManageLocator.java
+++
b/e2e/src/test/java/org/apache/dolphinscheduler/locator/security/UserManageLocator.java
@@ -42,7 +42,7 @@ public class UserManageLocator {
public static final By SUBMIT = By.xpath("//div[3]/button[2]/span");
- public static final By DELETE_USER_BUTTON = By.xpath("//span[2]/button/i");
+ public static final By DELETE_USER_BUTTON = By.xpath("//span[2]/button");
public static final By CONFIRM_DELETE_USER_BUTTON =
By.xpath("//div[2]/div/button[2]/span");
}
diff --git a/sql/upgrade/1.2.2_schema/mysql/dolphinscheduler_ddl.sql
b/sql/upgrade/1.2.2_schema/mysql/dolphinscheduler_ddl.sql
index 7432396..87d06e9 100644
--- a/sql/upgrade/1.2.2_schema/mysql/dolphinscheduler_ddl.sql
+++ b/sql/upgrade/1.2.2_schema/mysql/dolphinscheduler_ddl.sql
@@ -357,3 +357,24 @@ delimiter ;
CALL dc_dolphin_T_t_ds_error_command_D_worker_group_id;
DROP PROCEDURE dc_dolphin_T_t_ds_error_command_D_worker_group_id;
+-- ac_dolphin_T_t_ds_user_A_state
+drop PROCEDURE if EXISTS ac_dolphin_T_t_ds_user_A_state;
+delimiter d//
+CREATE PROCEDURE ac_dolphin_T_t_ds_user_A_state()
+ BEGIN
+ IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+ WHERE TABLE_NAME='t_ds_user'
+ AND TABLE_SCHEMA=(SELECT DATABASE())
+ AND COLUMN_NAME ='state')
+ THEN
+ ALTER TABLE t_ds_user ADD `state` int(1) DEFAULT 1 COMMENT 'state
0:disable 1:enable';
+ END IF;
+ END;
+
+d//
+
+delimiter ;
+CALL ac_dolphin_T_t_ds_user_A_state;
+DROP PROCEDURE ac_dolphin_T_t_ds_user_A_state;
+
+
diff --git a/sql/upgrade/1.2.2_schema/postgresql/dolphinscheduler_ddl.sql
b/sql/upgrade/1.2.2_schema/postgresql/dolphinscheduler_ddl.sql
index 5312d89..b3f5436 100644
--- a/sql/upgrade/1.2.2_schema/postgresql/dolphinscheduler_ddl.sql
+++ b/sql/upgrade/1.2.2_schema/postgresql/dolphinscheduler_ddl.sql
@@ -364,3 +364,23 @@ select dc_dolphin_T_t_ds_error_command_D_worker_group_id();
DROP FUNCTION dc_dolphin_T_t_ds_error_command_D_worker_group_id();
+-- ac_dolphin_T_t_ds_user_A_state
+delimiter ;
+DROP FUNCTION IF EXISTS ac_dolphin_T_t_ds_user_A_state();
+delimiter d//
+CREATE FUNCTION ac_dolphin_T_t_ds_user_A_state() RETURNS void AS $$
+BEGIN
+ IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
+ WHERE TABLE_CATALOG=current_database()
+ AND TABLE_SCHEMA=current_schema()
+ AND TABLE_NAME='t_ds_user'
+ AND COLUMN_NAME ='state')
+ THEN
+ ALTER TABLE t_ds_user ADD COLUMN state int DEFAULT 1;
+ END IF;
+END;
+$$ LANGUAGE plpgsql;
+d//
+delimiter ;
+select ac_dolphin_T_t_ds_user_A_state();
+DROP FUNCTION ac_dolphin_T_t_ds_user_A_state();
\ No newline at end of file