Search in sources :

Example 1 with Verify

use of app.hongs.action.anno.Verify in project HongsCORE by ihongs.

the class SignAction method signCreate.

/**
 * 登录
 * @param ah
 * @throws HongsException
 */
@Action("create")
@Verify(conf = "master", form = "sign")
public void signCreate(ActionHelper ah) throws HongsException {
    String appid = Synt.declare(ah.getParameter("appid"), "_WEB_");
    String place = Synt.declare(ah.getParameter("place"), "public");
    String username = Synt.declare(ah.getParameter("username"), "");
    String password = Synt.declare(ah.getParameter("password"), "");
    String passcode;
    DB db = DB.getInstance("master");
    Table tb = db.getTable("user");
    FetchCase fc;
    Map ud;
    // 验证密码
    fc = new FetchCase().from(tb.tableName).select("password, passcode, id, name, head, mtime, state").filter("username = ?", username);
    ud = db.fetchLess(fc);
    if (ud.isEmpty()) {
        ah.reply(AuthKit.getWrong("username", "core.username.invalid"));
        return;
    }
    passcode = Synt.declare(ud.get("passcode"), "");
    password = AuthKit.getCrypt(password + passcode);
    if (!password.equals(ud.get("password"))) {
        ah.reply(AuthKit.getWrong("passowrd", "core.password.invalid"));
        return;
    }
    String usrid = (String) ud.get("id");
    String uname = (String) ud.get("name");
    String uhead = (String) ud.get("head");
    int state = Synt.declare(ud.get("state"), 0);
    long utime = Synt.declare(ud.get("mtime"), 0L) * 1000;
    // 验证状态
    if (1 != state) {
        ah.reply(AuthKit.getWrong("state", "core.sign.state.invalid"));
        return;
    }
    // 验证区域
    Set rs = RoleSet.getInstance(usrid);
    if (0 != place.length() && !rs.contains(place)) {
        ah.reply(AuthKit.getWrong("place", "core.sign.place.invalid"));
        return;
    }
    ah.reply(AuthKit.userSign(ah, place, appid, usrid, uname, uhead, utime));
}
Also used : Table(app.hongs.db.Table) FetchCase(app.hongs.db.util.FetchCase) Set(java.util.Set) RoleSet(app.hongs.serv.auth.RoleSet) Map(java.util.Map) DB(app.hongs.db.DB) Action(app.hongs.action.anno.Action) Verify(app.hongs.action.anno.Verify)

Example 2 with Verify

use of app.hongs.action.anno.Verify 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
    if ("".equals(rd.get("password"))) {
        rd.remove("password");
        rd.remove("passcode");
    }
    String id = model.set(rd);
    Map sd = new HashMap();
    sd.put("id", id);
    sd.put("name", rd.get("name"));
    sd.put("head", rd.get("head"));
    CoreLocale ln = CoreLocale.getInstance().clone();
    ln.load("master");
    String ms = ln.translate("core.save.user.success");
    helper.reply(ms, sd);
}
Also used : CoreLocale(app.hongs.CoreLocale) HashMap(java.util.HashMap) HashMap(java.util.HashMap) NaviMap(app.hongs.action.NaviMap) Map(java.util.Map) RoleMap(app.hongs.serv.auth.RoleMap) Action(app.hongs.action.anno.Action) CommitSuccess(app.hongs.action.anno.CommitSuccess) Verify(app.hongs.action.anno.Verify)

Example 3 with Verify

use of app.hongs.action.anno.Verify in project HongsCORE by ihongs.

the class JointGate method create.

@Override
@Action("create")
@Preset(conf = "", form = "", deft = { ":create" })
@Select(conf = "", form = "", mode = 2)
@Verify(conf = "", form = "")
@CommitSuccess
public void create(ActionHelper helper) throws HongsException {
    IEntity sr = getEntity(helper);
    Map rd = helper.getRequestData();
    rd = getReqMap(helper, sr, "create", rd);
    Map sd = sr.create(rd);
    sd = getRspMap(helper, sr, "create", sd);
    String ss = getRspMsg(helper, sr, "create", 1);
    helper.reply(ss, sd);
}
Also used : NaviMap(app.hongs.action.NaviMap) Map(java.util.Map) Action(app.hongs.action.anno.Action) CommitSuccess(app.hongs.action.anno.CommitSuccess) Preset(app.hongs.action.anno.Preset) Select(app.hongs.action.anno.Select) Verify(app.hongs.action.anno.Verify)

Example 4 with Verify

use of app.hongs.action.anno.Verify in project HongsCORE by ihongs.

the class DBAction method create.

@Action("create")
@Preset(conf = "", form = "", deft = { ":create" })
@Select(conf = "", form = "", mode = 2)
@Verify(conf = "", form = "")
@CommitSuccess
@Override
public void create(ActionHelper helper) throws HongsException {
    Model ett = getEntity(helper);
    Map req = helper.getRequestData();
    req = getReqMap(helper, ett, "create", req);
    Map rsp = ett.create(req);
    rsp = getRspMap(helper, ett, "create", rsp);
    String msg = getRspMsg(helper, ett, "create", 1);
    helper.reply(msg, rsp);
}
Also used : Map(java.util.Map) Action(app.hongs.action.anno.Action) IAction(app.hongs.dh.IAction) CommitSuccess(app.hongs.action.anno.CommitSuccess) Preset(app.hongs.action.anno.Preset) Select(app.hongs.action.anno.Select) Verify(app.hongs.action.anno.Verify)

Example 5 with Verify

use of app.hongs.action.anno.Verify in project HongsCORE by ihongs.

the class DBAction method update.

@Action("update")
@Preset(conf = "", form = "", deft = { ":update" })
@Verify(conf = "", form = "")
@CommitSuccess
@Override
public void update(ActionHelper helper) throws HongsException {
    Model ett = getEntity(helper);
    Map req = helper.getRequestData();
    req = getReqMap(helper, ett, "update", req);
    int num = ett.update(req);
    String msg = getRspMsg(helper, ett, "update", num);
    helper.reply(msg, num);
}
Also used : Map(java.util.Map) Action(app.hongs.action.anno.Action) IAction(app.hongs.dh.IAction) CommitSuccess(app.hongs.action.anno.CommitSuccess) Preset(app.hongs.action.anno.Preset) Verify(app.hongs.action.anno.Verify)

Aggregations

Action (app.hongs.action.anno.Action)9 Verify (app.hongs.action.anno.Verify)9 Map (java.util.Map)9 CommitSuccess (app.hongs.action.anno.CommitSuccess)6 Preset (app.hongs.action.anno.Preset)5 HashMap (java.util.HashMap)4 NaviMap (app.hongs.action.NaviMap)3 CoreLocale (app.hongs.CoreLocale)2 Select (app.hongs.action.anno.Select)2 IAction (app.hongs.dh.IAction)2 DB (app.hongs.db.DB)1 Table (app.hongs.db.Table)1 FetchCase (app.hongs.db.util.FetchCase)1 RoleMap (app.hongs.serv.auth.RoleMap)1 RoleSet (app.hongs.serv.auth.RoleSet)1 User (app.hongs.serv.master.User)1 UserAction (app.hongs.serv.master.UserAction)1 Set (java.util.Set)1