mirror of https://github.com/Rekoe/rk_svnadmin
支持删除的账号可以过滤
parent
ab776d983b
commit
d730c0898c
|
@ -43,6 +43,10 @@ public class Usr implements Serializable {
|
|||
@Column
|
||||
private String email;
|
||||
|
||||
@Column("is_lock")
|
||||
@Default("0")
|
||||
private boolean lock;
|
||||
|
||||
/**
|
||||
* @return 用户ID
|
||||
*/
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
package com.rekoe.filter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.nutz.integration.shiro.NutShiro;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.mvc.ActionContext;
|
||||
import org.nutz.mvc.ActionFilter;
|
||||
import org.nutz.mvc.View;
|
||||
import org.nutz.mvc.view.UTF8JsonView;
|
||||
import org.nutz.mvc.view.ViewWrapper;
|
||||
import org.nutz.plugins.view.freemarker.FreeMarkerConfigurer;
|
||||
import org.nutz.plugins.view.freemarker.FreemarkerView;
|
||||
|
||||
import com.rekoe.common.Message;
|
||||
|
||||
@IocBean
|
||||
public class SelectServerActionFilter implements ActionFilter {
|
||||
|
||||
@Inject
|
||||
private FreeMarkerConfigurer freeMarkerConfigurer;
|
||||
|
||||
public View match(final ActionContext ctx) {
|
||||
HttpSession session = ctx.getRequest().getSession();
|
||||
Object sid = session.getAttribute("sid");
|
||||
if (Lang.isEmpty(sid)) {
|
||||
if (NutShiro.isAjax(ctx.getRequest())) {
|
||||
ctx.getResponse().setHeader("loginStatus", getResStatus());
|
||||
return new ViewWrapper(UTF8JsonView.COMPACT, getResStatus());
|
||||
}
|
||||
return getErrView(ctx.getRequest());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getResStatus() {
|
||||
return "select_server";
|
||||
}
|
||||
|
||||
public View getErrView(HttpServletRequest req) {
|
||||
return new ViewWrapper(new FreemarkerView(freeMarkerConfigurer, "template/admin/common/error"), Message.error("admin.common.error.no.server", req));
|
||||
}
|
||||
}
|
|
@ -59,8 +59,22 @@ public class AdminSvnUserAct extends BaseAction {
|
|||
@Ok("fm:template.admin.svn_user.list")
|
||||
@RequiresPermissions({ "svn.user:view" })
|
||||
@PermissionTag(name = "SVN浏览账号", tag = "SVN账号管理")
|
||||
public Pagination list(@Param(value = "pageNumber", df = "1") int page) {
|
||||
return svnUserService.getObjListByPager(page, 20, Cnd.where("usr", "<>", "*"));
|
||||
public Pagination list(@Param(value = "pageNumber", df = "1") int page, HttpServletRequest req) {
|
||||
req.setAttribute("page", page);
|
||||
req.setAttribute("action", "list.rk");
|
||||
req.setAttribute("lock", 0);
|
||||
return svnUserService.getObjListByPager(page, 20, Cnd.where("usr", "<>", "*").and("is_lock", "=", false));
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("fm:template.admin.svn_user.list")
|
||||
@RequiresPermissions({ "svn.user:view" })
|
||||
@PermissionTag(name = "SVN浏览账号", tag = "SVN账号管理")
|
||||
public Pagination lock_list(@Param(value = "pageNumber", df = "1") int page, HttpServletRequest req) {
|
||||
req.setAttribute("page", page);
|
||||
req.setAttribute("action", "lock_list.rk");
|
||||
req.setAttribute("lock", 1);
|
||||
return svnUserService.getObjListByPager(page, 20, Cnd.where("usr", "<>", "*").and("is_lock", "=", true));
|
||||
}
|
||||
|
||||
@At
|
||||
|
@ -194,6 +208,52 @@ public class AdminSvnUserAct extends BaseAction {
|
|||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("svn.user:add")
|
||||
@PermissionTag(name = "SVN添加账号", tag = "SVN账号管理", enable = false)
|
||||
public Message lock(@Param("usr") String usr, @Attr("usr") Usr manager, HttpServletRequest req) {
|
||||
Usr user = svnUserService.fetch(Cnd.where("usr", "=", usr));
|
||||
if (user == null) {
|
||||
return Message.error("error.account.empty", req);
|
||||
}
|
||||
String code = RandomStringUtils.random(7, RANDOM_ARRY_CHAR);
|
||||
boolean value = true;
|
||||
svnUserService.update(Chain.make("psw", EncryptUtil.encrypt(code)).add("is_lock", value), Cnd.where("usr", "=", usr));
|
||||
String salt = new SecureRandomNumberGenerator().nextBytes().toBase64();
|
||||
String pwd = new Sha256Hash(code, salt, 1024).toBase64();
|
||||
userService.update(Chain.make("salt", salt).add("password", pwd).add("is_locked", value), Cnd.where("name", "=", usr));
|
||||
if (usr.equals(manager.getUsr())) {
|
||||
req.getSession().setAttribute("usr", svnUserService.fetch(Cnd.where("usr", "=", usr)));
|
||||
}
|
||||
List<Pj> list = svnUserService.getPjList(usr);
|
||||
if (list != null) {
|
||||
for (Pj pj : list) {
|
||||
try {
|
||||
this.svnService.exportConfig(pj);
|
||||
} catch (Exception e) {
|
||||
log.errorf("project %s ,error %s", pj.getPj(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("json")
|
||||
@RequiresPermissions("svn.user:add")
|
||||
@PermissionTag(name = "SVN添加账号", tag = "SVN账号管理", enable = false)
|
||||
public Message unlock(@Param("usr") String usr, @Attr("usr") Usr manager, HttpServletRequest req) {
|
||||
Usr user = svnUserService.fetch(Cnd.where("usr", "=", usr));
|
||||
if (user == null) {
|
||||
return Message.error("error.account.empty", req);
|
||||
}
|
||||
boolean value = false;
|
||||
svnUserService.update(Chain.make("is_lock", value), Cnd.where("usr", "=", usr));
|
||||
userService.update(Chain.make("is_locked", value), Cnd.where("name", "=", usr));
|
||||
return Message.success("ok", req);
|
||||
}
|
||||
|
||||
@Async
|
||||
private void emailNotify(Usr user, EmailService emailService, ProjectConfig conf, String to, String pwd) {
|
||||
if (conf.isEmailNotify() && Strings.isEmail(to)) {
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package com.rekoe.mvc;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.ActionContext;
|
||||
import org.nutz.mvc.impl.processor.AbstractProcessor;
|
||||
|
||||
/**
|
||||
* 执行时间过滤器
|
||||
*/
|
||||
public class ProcessTimeProcessor extends AbstractProcessor {
|
||||
private final static Log log = Logs.get() ;
|
||||
/**
|
||||
* 请求执行开始时间
|
||||
*/
|
||||
public static final String START_TIME = "_start_time";
|
||||
|
||||
@Override
|
||||
public void process(ActionContext ac) throws Throwable {
|
||||
long time = System.currentTimeMillis();
|
||||
HttpServletRequest request = ac.getRequest();
|
||||
request.setAttribute(START_TIME, time);
|
||||
doNext(ac);
|
||||
time = System.currentTimeMillis() - time;
|
||||
log.debugf("process in {%s} ms: {%s}", time, request.getRequestURI());
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package com.rekoe.mvc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.nutz.mvc.NutFilter;
|
||||
|
||||
public class RkCmsNutFilter extends NutFilter {
|
||||
|
||||
protected Set<String> prefixs = new HashSet<String>();
|
||||
|
||||
|
||||
public void init(FilterConfig conf) throws ServletException {
|
||||
super.init(conf);
|
||||
prefixs.add(conf.getServletContext().getContextPath() + "/druid/");
|
||||
prefixs.add(conf.getServletContext().getContextPath() + "/res/");
|
||||
prefixs.add(conf.getServletContext().getContextPath() + "/thirdparty/");
|
||||
prefixs.add(conf.getServletContext().getContextPath() + "/tinyeditor/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
|
||||
if (req instanceof HttpServletRequest) {
|
||||
String uri = ((HttpServletRequest) req).getRequestURI();
|
||||
for (String prefix : prefixs) {
|
||||
if (uri.startsWith(prefix)) {
|
||||
chain.doFilter(req, resp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.doFilter(req, resp, chain);
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
var chain={
|
||||
"default" : {
|
||||
"ps" : [
|
||||
"org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor",
|
||||
"org.nutz.mvc.impl.processor.EncodingProcessor",
|
||||
"org.nutz.mvc.impl.processor.ModuleProcessor",
|
||||
"org.nutz.integration.shiro.NutShiroProcessor",
|
||||
"org.nutz.mvc.impl.processor.ActionFiltersProcessor",
|
||||
"org.nutz.mvc.impl.processor.AdaptorProcessor",
|
||||
"org.nutz.mvc.impl.processor.MethodInvokeProcessor",
|
||||
"com.rekoe.mvc.ProcessTimeProcessor",
|
||||
"org.nutz.mvc.impl.processor.ViewProcessor"
|
||||
],
|
||||
"error" : 'org.nutz.mvc.impl.processor.FailProcessor'
|
||||
}
|
||||
};
|
|
@ -67,7 +67,7 @@ public class ProjectGroupUsrService extends BaseService<PjGrUsr> {
|
|||
*/
|
||||
public Pagination getList(String pj, String gr, int page) {
|
||||
Pager pager = dao().createPager(page, 20);
|
||||
Sql sql = Sqls.create("select a.pj,a.usr,a.gr,b.name as usrname from pj_gr_usr a left join usr b on (a.usr = b.usr) where a.pj=@pj and a.gr=@gr order by a.usr");
|
||||
Sql sql = Sqls.create("select a.pj,a.usr,a.gr,b.name as usrname from pj_gr_usr a left join usr b on (a.usr = b.usr) where a.pj=@pj and a.gr=@gr and b.is_lock=false order by a.usr");
|
||||
sql.setParam("pj", pj).setParam("gr", gr);
|
||||
sql.setPager(pager);
|
||||
final List<PjGrUsr> list = new ArrayList<PjGrUsr>();
|
||||
|
@ -95,7 +95,7 @@ public class ProjectGroupUsrService extends BaseService<PjGrUsr> {
|
|||
* @return 项目的组用户列表
|
||||
*/
|
||||
public List<PjGrUsr> getList(String pj) {
|
||||
Sql sql = Sqls.create("select a.pj,a.gr,b.usr,c.name as usrname from pj_gr a left join pj_gr_usr b on (a.pj=b.pj and a.gr=b.gr) left join usr c on (b.usr = c.usr) where a.pj=@pj order by a.gr,b.usr");
|
||||
Sql sql = Sqls.create("select a.pj,a.gr,b.usr,c.name as usrname from pj_gr a left join pj_gr_usr b on (a.pj=b.pj and a.gr=b.gr) left join usr c on (b.usr = c.usr) where a.pj=@pj and c.is_lock=falsd order by a.gr,b.usr");
|
||||
sql.setParam("pj", pj);
|
||||
final List<PjGrUsr> list = new ArrayList<PjGrUsr>();
|
||||
sql.setCallback(new SqlCallback() {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class SvnUserService extends BaseService<Usr> {
|
|||
* @return 项目组未选的用户(不包括*)
|
||||
*/
|
||||
public List<Usr> listUnSelected(String pj, String gr) {
|
||||
Sql sql = Sqls.create("select usr,name,psw,email,role from usr a where a.usr <> '*' " + " and not exists (select usr from pj_gr_usr b where a.usr = b.usr and b.pj=@pj and b.gr=@gr) order by a.usr");
|
||||
Sql sql = Sqls.create("select usr,name,psw,email,role from usr a where a.usr <> '*' " + " and not exists (select usr from pj_gr_usr b where a.usr = b.usr and b.pj=@pj and b.gr=@gr) and a.is_lock=false order by a.usr");
|
||||
sql.setParam("pj", pj).setParam("gr", gr);
|
||||
final List<Usr> list = new ArrayList<Usr>();
|
||||
sql.setCallback(new SqlCallback() {
|
||||
|
@ -91,7 +91,7 @@ public class SvnUserService extends BaseService<Usr> {
|
|||
}
|
||||
|
||||
public List<Usr> listSelected(String pj) {
|
||||
Sql sql = Sqls.create("select * from usr a where a.usr <> '*' " + " and exists (select usr from pj_gr_usr b where a.usr = b.usr and b.pj=@pj) order by a.usr");
|
||||
Sql sql = Sqls.create("select * from usr a where a.usr <> '*' " + " and exists (select usr from pj_gr_usr b where a.usr = b.usr and b.pj=@pj) and a.is_lock=false order by a.usr");
|
||||
sql.setParam("pj", pj);
|
||||
final List<Usr> list = new ArrayList<Usr>();
|
||||
sql.setCallback(new SqlCallback() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.sql.SQLException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
|
@ -32,7 +33,7 @@ public class UsrService extends BaseService<Usr> {
|
|||
* @return 所有用户列表
|
||||
*/
|
||||
public List<Usr> getList() {
|
||||
return dao().query(getEntityClass(), null);
|
||||
return dao().query(getEntityClass(), Cnd.where("is_lock", "=", false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.rekoe.web.freemarker;
|
||||
|
||||
import static com.rekoe.mvc.ProcessTimeProcessor.START_TIME;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.text.DecimalFormat;
|
||||
|
@ -38,7 +36,7 @@ public class ProcessTimeDirective implements TemplateDirectiveModel {
|
|||
}
|
||||
|
||||
private long getStartTime(Environment env) throws TemplateModelException {
|
||||
TemplateModel startTime = env.getGlobalVariable(START_TIME);
|
||||
TemplateModel startTime = env.getGlobalVariable("_t_start");
|
||||
if (startTime == null) {
|
||||
log.warn("Variable '{}' not found in GlobalVariable", "START_TIME");
|
||||
return -1;
|
||||
|
@ -46,7 +44,7 @@ public class ProcessTimeDirective implements TemplateDirectiveModel {
|
|||
if (startTime instanceof TemplateNumberModel) {
|
||||
return ((TemplateNumberModel) startTime).getAsNumber().longValue();
|
||||
} else {
|
||||
throw new NutConfigException(START_TIME);
|
||||
throw new NutConfigException("_t_start");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@ h3{ padding:0; margin:0; font-weight:normal; font-size:12px;}
|
|||
<li><a href="${base}/admin/server/right" target="rightFrame"><@s.m "global.admin.index"/></a></li>
|
||||
<@perm_chow perm="svn.user">
|
||||
<li><a href="${base}/admin/svn/user/list.rk" target="rightFrame">账号列表</a></li>
|
||||
</@perm_chow>
|
||||
<@perm_chow perm="svn.user">
|
||||
<li><a href="${base}/admin/svn/user/lock_list.rk" target="rightFrame">已锁账号列表</a></li>
|
||||
</@perm_chow>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -11,7 +11,7 @@ function getTableForm() {
|
|||
function rest(usr){
|
||||
$.dialog({
|
||||
type: "warn",
|
||||
content: '确定要充值用户密码?',
|
||||
content: '确定要重置用户密码?',
|
||||
ok: 'Ok',
|
||||
cancel: 'Cancel',
|
||||
onOk: function() {
|
||||
|
@ -33,6 +33,38 @@ function rest(usr){
|
|||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function lock(usr,lock){
|
||||
var rl = 'lock.rk';
|
||||
var text = '确定要锁定此账号?';
|
||||
if(lock==1){
|
||||
text = '确定要解锁此账号?';
|
||||
rl = 'unlock.rk';
|
||||
}
|
||||
$.dialog({
|
||||
type: "warn",
|
||||
content: text,
|
||||
ok: 'Ok',
|
||||
cancel: 'Cancel',
|
||||
onOk: function() {
|
||||
$.ajax({
|
||||
url: rl,
|
||||
type: "POST",
|
||||
data: {"usr":usr},
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
success: function(message) {
|
||||
$.message(message);
|
||||
if (message.type == "success")
|
||||
{
|
||||
window.location.href = "${action}?pageNumber=${page}";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -58,6 +90,13 @@ function rest(usr){
|
|||
<@p.column title="密码重置" align="center">
|
||||
<a href="javascript:void(0);" onclick="rest('${user.usr}')" class="pn-opt">密码重置</a><#rt/>
|
||||
</@p.column><#t/>
|
||||
<@p.column title="账号锁定" align="center">
|
||||
<#if lock==0>
|
||||
<a href="javascript:void(0);" onclick="lock('${user.usr}','${lock}')" class="pn-opt">账号锁定</a><#rt/>
|
||||
<#else>
|
||||
<a href="javascript:void(0);" onclick="lock('${user.usr}','${lock}')" class="pn-opt">账号解锁</a><#rt/>
|
||||
</#if>
|
||||
</@p.column><#t/>
|
||||
</@shiro.hasPermission>
|
||||
</@p.table>
|
||||
</@p.form>
|
||||
|
|
|
@ -35,11 +35,15 @@
|
|||
</filter-mapping>
|
||||
<filter>
|
||||
<filter-name>nutz</filter-name>
|
||||
<filter-class>com.rekoe.mvc.RkCmsNutFilter</filter-class>
|
||||
<filter-class>org.nutz.mvc.NutFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>modules</param-name>
|
||||
<param-value>com.rekoe.MainModule</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>exclusions</param-name>
|
||||
<param-value>/res/*,*.html,/static/*</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>nutz</filter-name>
|
||||
|
@ -65,7 +69,7 @@
|
|||
<error-code>500</error-code>
|
||||
<location>/WEB-INF/jsp/500.jsp</location>
|
||||
</error-page>
|
||||
<session-config>
|
||||
<session-config>
|
||||
<!-- 一年 -->
|
||||
<session-timeout>946080000</session-timeout>
|
||||
</session-config>
|
||||
|
|
Loading…
Reference in New Issue