Search in sources :

Example 1 with User

use of me.zbl.fullstack.entity.User in project FS-Blog by JamesZBL.

the class UserController method fFrontUserLogin.

/**
 * 前台用户登录
 * 表单提交
 */
@PostMapping("/userlogin.f")
public String fFrontUserLogin(HttpServletRequest request, Model model, @Valid UserLoginForm loginForm, BindingResult bindingResult) throws Exception {
    if (bindingResult.hasErrors()) {
        List<ObjectError> errors = bindingResult.getAllErrors();
        addModelAtt(model, VIEW_MSG, errors.get(0).getDefaultMessage());
        return "userlogin";
    }
    User user = mUserService.loginAuthentication(loginForm);
    if (null != user) {
        mUserService.joinSession(request, user);
        return "redirect:/";
    }
    addModelAtt(model, VIEW_MSG, "用户名或密码错误");
    return "userlogin";
}
Also used : ObjectError(org.springframework.validation.ObjectError) User(me.zbl.fullstack.entity.User) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

User (me.zbl.fullstack.entity.User)1 ObjectError (org.springframework.validation.ObjectError)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1