Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
a2c9277c61
|
@ -1,18 +1,22 @@
|
|||
package io.metersphere.security;
|
||||
|
||||
|
||||
import io.metersphere.base.domain.Role;
|
||||
import io.metersphere.dto.UserDTO;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.user.SessionUser;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.*;
|
||||
import org.apache.shiro.authz.AuthorizationInfo;
|
||||
import org.apache.shiro.authz.SimpleAuthorizationInfo;
|
||||
import org.apache.shiro.realm.AuthorizingRealm;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -34,8 +38,16 @@ public class ShiroDBRealm extends AuthorizingRealm {
|
|||
* 权限认证
|
||||
*/
|
||||
@Override
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
|
||||
return null;
|
||||
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
|
||||
String userName = (String) principals.getPrimaryPrincipal();
|
||||
SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
|
||||
|
||||
// roles 内容填充
|
||||
UserDTO userDTO = userService.getUserDTO(userName);
|
||||
Set<String> roles = userDTO.getRoles().stream().map(Role::getId).collect(Collectors.toSet());
|
||||
authorizationInfo.setRoles(roles);
|
||||
|
||||
return authorizationInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,7 +65,7 @@ public class ShiroDBRealm extends AuthorizingRealm {
|
|||
logger.warn(msg);
|
||||
throw new UnknownAccountException(msg);
|
||||
}
|
||||
// TODO 密码验证,roles 等内容填充
|
||||
// TODO 密码验证
|
||||
|
||||
SessionUser sessionUser = SessionUser.fromUser(user);
|
||||
SecurityUtils.getSubject().getSession().setAttribute("user", sessionUser);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</span>
|
||||
</el-row>
|
||||
</div>
|
||||
<el-table :data="items" style="width: 100%">
|
||||
<el-table :data="items" style="width: 100%" v-loading="loading">
|
||||
<el-table-column prop="name" label="名称"/>
|
||||
<el-table-column prop="description" label="描述"/>
|
||||
<el-table-column>
|
||||
|
|
|
@ -133,15 +133,11 @@
|
|||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$get(this.deletePath + row.id).then(response => {
|
||||
if (response.data.success) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!'
|
||||
});
|
||||
} else {
|
||||
this.$message.error(response.message);
|
||||
}
|
||||
this.$get(this.deletePath + row.id,() => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!'
|
||||
});
|
||||
this.initTableData()
|
||||
});
|
||||
}).catch(() => {
|
||||
|
@ -154,18 +150,13 @@
|
|||
createOrganization(createOrganizationForm) {
|
||||
this.$refs[createOrganizationForm].validate( valide => {
|
||||
if (valide) {
|
||||
this.$post(this.createPath, this.form)
|
||||
.then(response => {
|
||||
if (response.data.success) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '添加成功!'
|
||||
});
|
||||
this.initTableData();
|
||||
} else {
|
||||
this.$message.error(response.message);
|
||||
}
|
||||
this.createVisible = false;
|
||||
this.$post(this.createPath, this.form,() => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '添加成功!'
|
||||
});
|
||||
this.initTableData();
|
||||
this.createVisible = false;
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
|
@ -175,19 +166,14 @@
|
|||
updateOrganization(udpateOrganizationForm) {
|
||||
this.$refs[udpateOrganizationForm].validate(valide => {
|
||||
if (valide) {
|
||||
this.$post(this.updatePath, this.form)
|
||||
.then(response => {
|
||||
if (response.data.success) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '修改成功!'
|
||||
});
|
||||
this.updateVisible = false;
|
||||
} else {
|
||||
this.$message.error(response.message);
|
||||
}
|
||||
this.initTableData();
|
||||
self.loading = false;
|
||||
this.$post(this.updatePath, this.form,() => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '修改成功!'
|
||||
});
|
||||
this.updateVisible = false;
|
||||
this.initTableData();
|
||||
self.loading = false;
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
|
@ -195,14 +181,10 @@
|
|||
})
|
||||
},
|
||||
initTableData() {
|
||||
this.$post(this.buildPagePath(this.queryPath)).then(response => {
|
||||
if (response.data.success) {
|
||||
let data = response.data.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
} else {
|
||||
this.$message.error(response.message);
|
||||
}
|
||||
this.$post(this.buildPagePath(this.queryPath),{},response => {
|
||||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
})
|
||||
},
|
||||
closeFunc() {
|
||||
|
|
|
@ -180,16 +180,12 @@
|
|||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$get(this.deletePath + row.id).then(response => {
|
||||
if (response.data.success) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!'
|
||||
});
|
||||
this.initTableData()
|
||||
} else {
|
||||
this.$message.error(response.message)
|
||||
}
|
||||
this.$get(this.deletePath + row.id, () => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!'
|
||||
});
|
||||
this.initTableData();
|
||||
});
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
|
@ -201,18 +197,13 @@
|
|||
createUser(createUserForm) {
|
||||
this.$refs[createUserForm].validate(valide => {
|
||||
if (valide) {
|
||||
this.$post(this.createPath, this.form)
|
||||
.then(response => {
|
||||
if (response.data.success) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '添加成功!'
|
||||
});
|
||||
this.initTableData();
|
||||
} else {
|
||||
this.$message.error(response.message);
|
||||
}
|
||||
this.createVisible = false;
|
||||
this.$post(this.createPath, this.form, () => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '添加成功!'
|
||||
});
|
||||
this.initTableData();
|
||||
this.createVisible = false;
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
|
@ -222,19 +213,14 @@
|
|||
updateUser(updateUserForm) {
|
||||
this.$refs[updateUserForm].validate(valide => {
|
||||
if (valide) {
|
||||
this.$post(this.updatePath, this.form)
|
||||
.then(response => {
|
||||
if (response.data.success) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '修改成功!'
|
||||
});
|
||||
this.updateVisible = false;
|
||||
} else {
|
||||
this.$message.error(response.message);
|
||||
}
|
||||
this.initTableData();
|
||||
self.loading = false;
|
||||
this.$post(this.updatePath, this.form,() => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '修改成功!'
|
||||
});
|
||||
this.updateVisible = false;
|
||||
this.initTableData();
|
||||
self.loading = false;
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
|
@ -242,29 +228,21 @@
|
|||
})
|
||||
},
|
||||
initTableData() {
|
||||
this.$post(this.buildPagePath(this.queryPath)).then(response => {
|
||||
if (response.data.success) {
|
||||
let data = response.data.data;
|
||||
this.$post(this.buildPagePath(this.queryPath),{},response => {
|
||||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
this.tableData = data.listObject;
|
||||
} else {
|
||||
this.$message.error(response.message);
|
||||
}
|
||||
})
|
||||
},
|
||||
closeFunc() {
|
||||
this.form = {};
|
||||
},
|
||||
changeSwitch(row) {
|
||||
this.$post(this.updatePath, row).then(response =>{
|
||||
if (response.data.success) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '状态修改成功!'
|
||||
});
|
||||
} else {
|
||||
this.$message.error(response.message);
|
||||
}
|
||||
this.$post(this.updatePath, row,() =>{
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '状态修改成功!'
|
||||
});
|
||||
})
|
||||
},
|
||||
buildPagePath(path) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div v-loading="loading">
|
||||
<div>
|
||||
<el-card>
|
||||
<div slot="header">
|
||||
<el-row type="flex" justify="space-between" align="middle">
|
||||
|
@ -13,7 +13,7 @@
|
|||
</span>
|
||||
</el-row>
|
||||
</div>
|
||||
<el-table :data="items" style="width: 100%">
|
||||
<el-table :data="items" style="width: 100%" v-loading="loading">
|
||||
<el-table-column prop="name" label="名称"/>
|
||||
<el-table-column prop="description" label="描述"/>
|
||||
<el-table-column>
|
||||
|
|
Loading…
Reference in New Issue