use of io.github.ihongs.action.anno.CommitSuccess in project HongsCORE by ihongs.
the class DeptAction method doSave.
@Action("save")
@CommitSuccess
public void doSave(ActionHelper helper) throws HongsException {
Map rd = helper.getRequestData();
String id = model.set(rd);
CoreLocale ln = CoreLocale.getInstance().clone();
ln.load("master");
String ms = ln.translate("core.save.dept.success");
helper.reply(ms, id);
}
use of io.github.ihongs.action.anno.CommitSuccess in project HongsCORE by ihongs.
the class UserAction method doDelete.
@Action("delete")
@CommitSuccess
public void doDelete(ActionHelper helper) throws HongsException {
// 不能删除自己和超级管理员
Set rs = Synt.asSet(helper.getParameter(Cnst.ID_KEY));
if (rs != null) {
if (rs.contains(helper.getSessibute(Cnst.UID_SES))) {
helper.fault("不能删除当前登录用户");
return;
}
if (rs.contains(Cnst.ADM_UID)) {
helper.fault("不能删除超级管理账号");
return;
}
}
Map rd = helper.getRequestData();
int rn = model.delete(rd);
CoreLocale ln = CoreLocale.getInstance().clone();
ln.load("master");
String ms = ln.translate("core.delete.user.success", null, Integer.toString(rn));
helper.reply(ms, rn);
}
use of io.github.ihongs.action.anno.CommitSuccess in project HongsCORE by ihongs.
the class UserAction method doSave.
@Action("save")
@Verify(conf = "master", form = "user")
@CommitSuccess
public void doSave(ActionHelper helper) throws HongsException {
Map rd = helper.getRequestData();
// Ignore empty password in update
boolean cp;
if (null == rd.get("password") || "".equals(rd.get("password"))) {
rd.remove("password");
rd.remove("passcode");
cp = false;
} else if (null == rd.get("id") || "".equals(rd.get("id"))) {
cp = false;
} else {
cp = true;
}
String id = model.set(rd);
CoreLocale ln = CoreLocale.getInstance().clone();
ln.load("master");
String ms = ln.translate("core.save.user.success");
helper.reply(ms, id);
/**
* 2019/02/26
* 有修改密码则将重试次数归零,
* 若密码重试次数标记有用到IP,
* 需告知登录的校验标记改用ID.
*
* 2021/06/20
* 已加修改密码需重新登录逻辑,
* 重写会话规避当前用户重登录.
*/
if (cp) {
Calendar ca;
long et;
ca = Calendar.getInstance(Core.getTimezone());
ca.setTimeInMillis(Core.ACTION_TIME.get());
ca.set(Calendar.HOUR_OF_DAY, 23);
ca.set(Calendar.MINUTE, 59);
ca.set(Calendar.SECOND, 59);
et = ca.getTimeInMillis() / 1000 + 1;
Record.set("sign.retry.allow." + id, 1, et);
Record.del("sign.retry.times." + id);
if ("*".equals(helper.getSessibute(Cnst.USK_SES))) {
helper.setSessibute(Cnst.UST_SES, System.currentTimeMillis() / 1000);
}
}
}
use of io.github.ihongs.action.anno.CommitSuccess in project HongsCORE by ihongs.
the class QQAction method inWeb.
/**
* QQ Web 登录回调
* @param helper
* @throws HongsException
*/
@Action("web/create")
@CommitSuccess
public void inWeb(ActionHelper helper) throws HongsException {
CoreConfig cc = CoreConfig.getInstance("oauth2");
String appId = cc.getProperty("oauth2.qq.web.app.id");
String appSk = cc.getProperty("oauth2.qq.web.app.key");
String rurl = cc.getProperty("oauth2.qq.wap.bak.url");
String code = helper.getParameter("code");
if (appId == null || appSk == null) {
helper.error(400, "Not support this mode");
}
try {
Map info = getUserInfo(code, appId, appSk, rurl, false);
String opnId = (String) info.get("opnid");
String opuId = (String) info.get("opuid");
String name = (String) info.get("name");
String head = (String) info.get("head");
Map back = AuthKit.openSign(helper, "qq", Synt.defoult(opuId, opnId), name, head);
// 登记 openId
if (opnId != null && opuId != null) {
String usrId = (String) back.get(Cnst.UID_SES);
setUserSign("qq.web", opnId, usrId);
}
AuthKit.redirect(helper, back);
} catch (HongsException ex) {
AuthKit.redirect(helper, ex);
}
}
use of io.github.ihongs.action.anno.CommitSuccess in project HongsCORE by ihongs.
the class QQAction method inWap.
/**
* QQ WAP 登录回调
* @param helper
* @throws HongsException
*/
@Action("wap/create")
@CommitSuccess
public void inWap(ActionHelper helper) throws HongsException {
CoreConfig cc = CoreConfig.getInstance("oauth2");
String appId = cc.getProperty("oauth2.qq.wap.app.id");
String appSk = cc.getProperty("oauth2.qq.wap.app.key");
String rurl = cc.getProperty("oauth2.qq.wap.bak.url");
String code = helper.getParameter("code");
if (appId == null || appSk == null) {
helper.error(400, "Not support this mode");
}
try {
Map info = getUserInfo(code, appId, appSk, rurl, true);
String opnId = (String) info.get("opnid");
String opuId = (String) info.get("opuid");
String name = (String) info.get("name");
String head = (String) info.get("head");
Map back = AuthKit.openSign(helper, "qq", Synt.defoult(opuId, opnId), name, head);
// 登记 openId
if (opnId != null && opuId != null) {
String usrId = (String) back.get(Cnst.UID_SES);
setUserSign("qq.wap", opnId, usrId);
}
AuthKit.redirect(helper, back);
} catch (HongsException ex) {
AuthKit.redirect(helper, ex);
}
}
Aggregations