package com.jfinal.club.my.safe;

import com.jfinal.aop.Inject;
import com.jfinal.club.reg.RegService;
import com.jfinal.core.Controller;
import com.jfinal.kit.Ret;
import com.jfinal.validate.Validator;

import java.util.Map;

/**
 * @ClassName UsersValidator
 * @Description TODO
 * @Author caolong
 * @Date 2020/3/17 17:44
 */
public class UsersPwdValidator extends Validator {


    protected void validate(Controller c) {
        setShortCircuit(true);
        setRet(Ret.fail());
        if ("1".equals(c.getPara("type"))) {
            if (!c.getPara("pwds").equals(c.getPara("rpwds"))) {
                addError("msg", "俩次密码输入不一致");
            }
        } else {
            validateRequired("oldpwds", "msg", "旧密码不能为空");
            validateRequired("newpwds", "msg", "新密码不能为空");
            validateRequired("rnewpwds", "msg", "确认密码不能为空");
        }
    }


    protected void handleError(Controller c) {
        Ret ret = getRet();
        c.renderJson(ret);
    }
}
