| | |
| | | |
| | | import com.vci.ubcs.code.service.IPasswordFreeLoginService; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import static com.vci.ubcs.starter.util.AESUtils.aesDecrypt; |
| | | import static com.vci.ubcs.starter.util.AESUtils.aesEncrypt; |
| | | |
| | | /** |
| | | * @author ludc |
| | |
| | | @RestController |
| | | @RequestMapping("/passwordFree") |
| | | @Api(value = "免密登录接口", tags = "免密登录接口") |
| | | @Slf4j |
| | | public class PasswordFreeLoginController { |
| | | |
| | | @Resource |
| | | private IPasswordFreeLoginService passwordFreeLoginService; |
| | | |
| | | @PostMapping("/login") |
| | | public String passwordFreeLogin(@RequestParam String username, HttpServletRequest request) { |
| | | String token = ""; |
| | | public R passwordFreeLogin(@RequestParam("userName") String username, HttpServletRequest request) { |
| | | boolean status; |
| | | try { |
| | | token = passwordFreeLoginService.passwordFreeLogin(username,request); |
| | | status = passwordFreeLoginService.pwdFreeLoginByBoolean(username,request); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("免密登录获取token失败:"+e.getMessage()); |
| | | } |
| | | return token; |
| | | return R.status(status); |
| | | } |
| | | |
| | | /** |
| | | * 单点登录 |
| | | * @param request |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @GetMapping("/ssoLogin") |
| | | public ModelAndView oaSsoLogin(HttpServletRequest request, ModelAndView model){ |
| | | String token; |
| | | try { |
| | | token = passwordFreeLoginService.ssoFreeLogin(request); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("单点登录获取token失败:"+e.getMessage()); |
| | | } |
| | | model.addObject("token",token); |
| | | model.setViewName("sso"); |
| | | return model; |
| | | } |
| | | |
| | | } |