|
|
@@ -10,10 +10,12 @@ import org.nutz.ioc.loader.annotation.Inject;
|
|
|
import org.nutz.ioc.loader.annotation.IocBean;
|
|
|
import org.nutz.lang.Strings;
|
|
|
import org.nutz.lang.util.NutMap;
|
|
|
+import org.nutz.mvc.Scope;
|
|
|
import org.nutz.mvc.annotation.*;
|
|
|
import org.nutz.mvc.filter.CheckSession;
|
|
|
import xyz.luxnk.lproject.bean.UserInfo;
|
|
|
import xyz.luxnk.lproject.bean.UserProfile;
|
|
|
+import xyz.luxnk.lproject.util.Toolkit;
|
|
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
import java.util.Date;
|
|
|
@@ -47,13 +49,17 @@ public class UserModule extends BaseModule {
|
|
|
*/
|
|
|
@At
|
|
|
@Filters() // 覆盖UserModule类的@Filters设置,因为登录可不能要求是个已经登陆的Session
|
|
|
- public Object login(@Param("username")String username, @Param("password")String password, HttpSession session) {
|
|
|
+ public Object login(@Param("username")String username, @Param("password")String password, @Param("captcha")String captcha, @Attr(scope = Scope.SESSION, value = "nutz_captcha")String _captcha, HttpSession session) {
|
|
|
+ NutMap re = new NutMap();
|
|
|
+ if (!Toolkit.checkCaptcha(_captcha, captcha)) {
|
|
|
+ return re.setv("ok", false).setv("msg", "验证码错误");
|
|
|
+ }
|
|
|
UserInfo userInfo = dao.fetch(UserInfo.class, Cnd.where("username", "=", username).and("password", "=", password));
|
|
|
if (userInfo == null) {
|
|
|
- return false;
|
|
|
+ return re.setv("ok", false).setv("msg", "用户名或密码错误");
|
|
|
} else {
|
|
|
session.setAttribute("me", userInfo.getId());
|
|
|
- return true;
|
|
|
+ return re.setv("ok", true);
|
|
|
}
|
|
|
}
|
|
|
|