public ShopAdmin adminLogin( HttpServletRequest request, HttpServletResponse response, Website web, String username, String password) throws UsernameNotFoundException, BadCredentialsException, UserNotInWebsiteException { Long webId = web.getId(); // 先退出登录 logout(request, response); User user = login(username, password); ShopAdmin admin = shopAdminMng.getByUserId(user.getId(), webId); if (admin == null) { throw new UserNotInWebsiteException( "user '" + user.getUsername() + "' not in Website '" + webId + "'"); } userMng.updateLoginInfo(user.getId(), request.getRemoteAddr()); session.setAttribute(request, response, SESSION_USER_ID_KEY, user.getId()); session.setAttribute(request, response, SESSION_ADMIN_ID_KEY, admin.getId()); addUsernameCookie(admin.getUsername(), null, null, request, response); return admin; }