use of com.duan.blogos.entity.blogger.BloggerAccount in project BlogSystem by DuanJiaNing.
the class FavouriteBlogPageController method setCommon.
private void setCommon(ModelAndView mv, HttpServletRequest request, String bloggerName) {
mv.setViewName("/blogger/favourite_blog");
// 登陆博主 id
int loginBloggerId = sessionManager.getLoginBloggerId(request);
ResultBean<BloggerStatisticsDTO> loginBgStat = statisticsService.getBloggerStatistics(loginBloggerId);
mv.addObject("loginBgStat", loginBgStat.getData());
BloggerAccount account = accountService.getAccount(bloggerName);
mv.addObject(bloggerProperties.getNameOfPageOwnerBloggerId(), account.getId());
mv.addObject(bloggerProperties.getNameOfPageOwnerBloggerName(), account.getUsername());
}
use of com.duan.blogos.entity.blogger.BloggerAccount in project BlogSystem by DuanJiaNing.
the class BloggerLoginController method loginWithPhoneNumber.
@RequestMapping(value = "/way=phone", method = RequestMethod.POST)
public ResultBean loginWithPhoneNumber(HttpServletRequest request, @RequestParam("phone") String phone) {
handlePhoneCheck(phone, request);
BloggerAccount account = accountService.getAccountByPhone(phone);
if (account == null)
return new ResultBean<>("", ResultBean.FAIL);
HttpSession session = request.getSession();
session.setAttribute(bloggerProperties.getSessionNameOfBloggerId(), account.getId());
session.setAttribute(bloggerProperties.getSessionNameOfBloggerName(), account.getUsername());
session.setAttribute(bloggerProperties.getSessionBloggerLoginSignal(), "login");
// 成功登录
return new ResultBean<>(account.getUsername());
}
use of com.duan.blogos.entity.blogger.BloggerAccount in project BlogSystem by DuanJiaNing.
the class BloggerLoginController method loginWithUserName.
@RequestMapping(value = "/way=name", method = RequestMethod.POST)
public ResultBean loginWithUserName(HttpServletRequest request, @RequestParam("username") String userName, @RequestParam("password") String password) throws NoSuchAlgorithmException {
// TODO 使用shiro
BloggerAccount account = accountService.getAccount(userName);
if (account != null && account.getUsername().equals(userName) && account.getPassword().equals(new BigInteger(StringUtils.toSha(password)).toString())) {
HttpSession session = request.getSession();
session.setAttribute(bloggerProperties.getSessionNameOfBloggerId(), account.getId());
session.setAttribute(bloggerProperties.getSessionNameOfBloggerName(), account.getUsername());
session.setAttribute(bloggerProperties.getSessionBloggerLoginSignal(), "login");
// 成功登录
return new ResultBean<>("");
} else {
// TODO 判断登录失败的原因
String errorMsg = messageManager.getLoginFailMessage(new RequestContext(request), false);
request.getServletContext().setAttribute(bloggerProperties.getSessionNameOfErrorMsg(), errorMsg);
return new ResultBean(exceptionManager.getLoginFailException(new RequestContext(request), false));
}
}
Aggregations