mirror of https://github.com/Rekoe/rk_svnadmin
重置账号
parent
50a3d85581
commit
c3a061b020
|
@ -14,7 +14,10 @@ import org.nutz.dao.Cnd;
|
|||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Attr;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
|
@ -27,6 +30,7 @@ import com.rekoe.domain.Usr;
|
|||
import com.rekoe.module.BaseAction;
|
||||
import com.rekoe.service.EmailService;
|
||||
import com.rekoe.service.ProjectConfigService;
|
||||
import com.rekoe.service.ProjectService;
|
||||
import com.rekoe.service.SvnService;
|
||||
import com.rekoe.service.SvnUserService;
|
||||
import com.rekoe.utils.EncryptUtil;
|
||||
|
@ -35,6 +39,8 @@ import com.rekoe.utils.EncryptUtil;
|
|||
@At("/admin/svn/user")
|
||||
public class AdminSvnUserAct extends BaseAction {
|
||||
|
||||
private final static Log log = Logs.get();
|
||||
|
||||
private static final char[] RANDOM_ARRY_CHAR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();
|
||||
|
||||
@Inject
|
||||
|
@ -79,6 +85,9 @@ public class AdminSvnUserAct extends BaseAction {
|
|||
@Inject
|
||||
private SvnService svnService;
|
||||
|
||||
@Inject
|
||||
private ProjectService projectService;
|
||||
|
||||
/**
|
||||
* 重置账号密码
|
||||
*
|
||||
|
@ -90,17 +99,25 @@ public class AdminSvnUserAct extends BaseAction {
|
|||
@Ok("json")
|
||||
@RequiresPermissions("svn.user:add")
|
||||
@PermissionTag(name = "SVN添加账号", tag = "SVN账号管理", enable = false)
|
||||
public Message restpwd(@Param("usr") String usr, HttpServletRequest req) {
|
||||
public Message restpwd(@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);
|
||||
svnUserService.update(Chain.make("psw", EncryptUtil.encrypt(code)), Cnd.where("usr", "=", 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) {
|
||||
this.svnService.exportConfig(pj);
|
||||
try {
|
||||
this.svnService.exportConfig(pj);
|
||||
} catch (Exception e) {
|
||||
projectService.deleteDB(pj.getPj());
|
||||
log.errorf("project %s ,error %s", pj.getPj(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
ProjectConfig conf = projectConfigService.get();
|
||||
|
|
|
@ -163,11 +163,15 @@ public class ProjectService extends BaseService<Pj> {
|
|||
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void delete(String pj) {
|
||||
deleteDB(pj);
|
||||
svnService.exportConfig(pj);
|
||||
}
|
||||
|
||||
public void deleteDB(String pj) {
|
||||
projectAuthService.deletePj(pj);
|
||||
projectGroupUsrService.deletePj(pj);
|
||||
projectGroupService.deletePj(pj);
|
||||
projectUserService.deletePj(pj);
|
||||
svnService.exportConfig(pj);
|
||||
dao().clear(getEntityClass(), Cnd.where("pj", "=", pj));
|
||||
}
|
||||
|
||||
|
@ -181,7 +185,7 @@ public class ProjectService extends BaseService<Pj> {
|
|||
* @return 用户有权限的项目列表(用户是否是这个项目的管理员)
|
||||
*/
|
||||
public List<Pj> getList(String usr) {
|
||||
Sql sql = Sqls.create("select p.pj,p.path,p.url,p.des,p.type,pm.pj manager from ( " + " select distinct a.pj,a.path,a.url,a.des,a.type from pj a where " + " exists (select b.usr from pj_gr_usr b where a.pj=b.pj and b.usr=@usr) " + " or exists(select c.usr from pj_usr_auth c where a.pj=c.pj and c.usr=@usr) " + " ) p " + " left join ( " + " select distinct a.pj from pj a where " + " exists (select b.usr from pj_gr_usr b where a.pj=b.pj and b.usr=@usr and b.gr like @like)" + " ) pm on p.pj=pm.pj");
|
||||
Sql sql = Sqls.create("select p.pj,p.des,p.type,pm.pj manager from ( " + " select distinct a.pj,a.des,a.type from pj a where " + " exists (select b.usr from pj_gr_usr b where a.pj=b.pj and b.usr=@usr) " + " or exists(select c.usr from pj_usr_auth c where a.pj=c.pj and c.usr=@usr) " + " ) p " + " left join ( " + " select distinct a.pj from pj a where " + " exists (select b.usr from pj_gr_usr b where a.pj=b.pj and b.usr=@usr and b.gr like @like)" + " ) pm on p.pj=pm.pj");
|
||||
final List<Pj> list = new ArrayList<Pj>();
|
||||
sql.setCallback(new SqlCallback() {
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ public class RepositoryService {
|
|||
result = StringUtils.replace(result, "\b", " ");
|
||||
result = StringUtils.replace(result, "<", " ");// eg. <br/>
|
||||
result = StringUtils.replace(result, "(", " ");// eg. ()
|
||||
|
||||
result = result.trim();
|
||||
int blank = result.indexOf(" ");
|
||||
if (blank != -1) {
|
||||
|
|
Loading…
Reference in New Issue