/* * Copyright 2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ssbusy.controller.account; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.broadleafcommerce.common.exception.ServiceException; import org.broadleafcommerce.core.web.controller.account.BroadleafLoginController; import org.broadleafcommerce.core.web.controller.account.ResetPasswordForm; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; /** * The controller responsible for all actions involving logging a customer in */ @Controller public class LoginController extends BroadleafLoginController { @RequestMapping("/login") public String login(HttpServletRequest request, HttpServletResponse response, Model model) { return super.login(request, response, model); } @RequestMapping(value = "/login/forgotPassword", method = RequestMethod.GET) public String forgotPassword(HttpServletRequest request, HttpServletResponse response, Model model) { return super.forgotPassword(request, response, model); } @RequestMapping(value = "/login/forgotPassword", method = RequestMethod.POST) public String processForgotPassword( @RequestParam("emailAddress") String emailAddress, HttpServletRequest request, Model model) { return super.processForgotPassword(emailAddress, request, model); } @RequestMapping(value = "/login/resetPassword", method = RequestMethod.GET) public String resetPassword(HttpServletRequest request, HttpServletResponse response, Model model) { return super.resetPassword(request, response, model); } @RequestMapping(value = "/login/resetPassword", method = RequestMethod.POST) public String processResetPassword( @ModelAttribute("resetPasswordForm") ResetPasswordForm resetPasswordForm, HttpServletRequest request, HttpServletResponse response, Model model, BindingResult errors) throws ServiceException { return super.processResetPassword(resetPasswordForm, request, response, model, errors); } @Override public String getResetPasswordUrl(HttpServletRequest request) { String url = request.getScheme() + "://" + request.getServerName() + getResetPasswordPort(request, request.getScheme() + "/"); if (request.getContextPath() != null && !"".equals(request.getContextPath())) { url = url + request.getContextPath() + "/login/resetPassword"; } else { url = url + "/login/resetPassword"; } return url; } // app ////////////////////////////////////////////// @RequestMapping("/app/login") @ResponseBody public Map<String, String> showLogin( @RequestParam(value = "error", required = false) String failLogin) { Map<String, String> ret = new HashMap<String, String>(2); ret.put("error", "login"); if (failLogin != null) ret.put("errorCode", "1"); return ret; } /** * app 登录成功后默认响应。 */ @RequestMapping("/app/logined") @ResponseBody public Map<String, String> logined() { return Collections.emptyMap(); } }