@Test public void testLogin() throws Exception { JSONObject jsonObject = new JSONObject(); jsonObject.put("username", "18381690821"); jsonObject.put("password", "123456"); post("/api/v1/auth/login", jsonObject.toJSONString()); }
@ResponseBody @RequestMapping(value = "/api/v1/pub/auth/login", method = RequestMethod.POST) public JSONObject login(@RequestBody(required = true) CaptchaUsernamePasswordToken token) { Subject subject = SecurityUtils.getSubject(); token.setRememberMe(false); if (!subject.isAuthenticated()) { String msg = null; try { subject.login(token); return success(); } catch (UnknownAccountException e) { msg = "账号错误"; return fail(-1, msg); } catch (LockedAccountException e) { msg = "账号被禁用"; return fail(-1, msg); } catch (ExcessiveAttemptsException e) { msg = e.getMessage(); return fail(-2, msg); } catch (AuthenticationException e) { msg = "用户名或密码错误"; return fail(-1, msg); } } else { return success(); } }
AuthorController extends BaseController { @ResponseBody @RequestMapping(value = "/api/v1/pub/auth/login", method = RequestMethod.POST) public JSONObject login(@RequestBody(required = true) CaptchaUsernamePasswordToken token) { Subject subject = SecurityUtils.getSubject(); token.setRememberMe(false); if (!subject.isAuthenticated()) { String msg = null; try { subject.login(token); return success(); } catch (UnknownAccountException e) { msg = "账号错误"; return fail(-1, msg); } catch (LockedAccountException e) { msg = "账号被禁用"; return fail(-1, msg); } catch (ExcessiveAttemptsException e) { msg = e.getMessage(); return fail(-2, msg); } catch (AuthenticationException e) { msg = "用户名或密码错误"; return fail(-1, msg); } } else { return success(); } } }
AuthorController extends BaseController { @ResponseBody @RequestMapping(value = "/api/v1/pub/auth/login", method = RequestMethod.POST) public JSONObject login(@RequestBody(required = true) CaptchaUsernamePasswordToken token) { Subject subject = SecurityUtils.getSubject(); token.setRememberMe(false); if (!subject.isAuthenticated()) { String msg = null; try { subject.login(token); return success(); } catch (UnknownAccountException e) { msg = "账号错误"; return fail(-1, msg); } catch (LockedAccountException e) { msg = "账号被禁用"; return fail(-1, msg); } catch (ExcessiveAttemptsException e) { msg = e.getMessage(); return fail(-2, msg); } catch (AuthenticationException e) { msg = "用户名或密码错误"; return fail(-1, msg); } } else { return success(); } }  }
AuthorController extends BaseController { @ResponseBody @RequestMapping(value = "/api/v1/pub/auth/login", method = RequestMethod.POST) public JSONObject login(@RequestBody(required = true) CaptchaUsernamePasswordToken token) { Subject subject = SecurityUtils.getSubject(); token.setRememberMe(false); if (!subject.isAuthenticated()) { String msg = null; try { subject.login(token); return success(); } catch (UnknownAccountException e) { msg = "账号错误"; return fail(-1, msg); } catch (LockedAccountException e) { msg = "账号被禁用"; return fail(-1, msg); } catch (ExcessiveAttemptsException e) { msg = e.getMessage(); return fail(-2, msg); } catch (AuthenticationException e) { msg = "用户名或密码错误"; return fail(-1, msg); } } else { return success(); } }  @RequestMapping(value = "/api/v1/pub/error/403", method = {RequestMethod.GET, RequestMethod.POST}) JSONObject error403(); @ApiOperation(value = "partyLogin", notes = "第三方登录", httpMethod = "POST") @ApiImplicitParams( { @ApiImplicitParam(name = "openid", value = "openid", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "platform", value = "平台类型,1=QQ,2=微信", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "nickName", value = "昵称", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "headImg", value = "平台类型,1=QQ,2=微信", paramType = "query", dataType = "string") } ) @RequestMapping(value = "/api/v1/pub/party/login", method = {RequestMethod.POST, RequestMethod.GET}) JSONObject partyLogin(
            @RequestParam(value = "openid", required = true) String openid,
            @RequestParam(value = "access_token", required = true) String accessToken,
            @RequestParam(value = "platform", required = true) int platform,
            @RequestParam(value = "nickName", required = true) String nickName,
            @RequestParam(value = "headImg", required = true) String headImg
    ); @ResponseBody @RequestMapping(value = "/api/v1/pub/auth/login", method = RequestMethod.POST) JSONObject login(@RequestBody(required = true) CaptchaUsernamePasswordToken token); @ResponseBody @RequestMapping(value = "/api/v1/pub/auth/logout", method = {RequestMethod.POST, RequestMethod.GET}) void logout(); @ResponseBody @RequestMapping(value = "/api/v1/pub/auth/register", method = RequestMethod.POST) JSONObject register(
            @RequestParam("phone") String phone,
            @RequestParam("password") String password,
            @RequestParam("SMSCode") String smscode); }
AuthorController extends BaseController { @ResponseBody @RequestMapping(value = "/api/v1/pub/auth/login", method = RequestMethod.POST) public JSONObject login(@RequestBody(required = true) CaptchaUsernamePasswordToken token) { Subject subject = SecurityUtils.getSubject(); token.setRememberMe(false); if (!subject.isAuthenticated()) { String msg = null; try { subject.login(token); return success(); } catch (UnknownAccountException e) { msg = "账号错误"; return fail(-1, msg); } catch (LockedAccountException e) { msg = "账号被禁用"; return fail(-1, msg); } catch (ExcessiveAttemptsException e) { msg = e.getMessage(); return fail(-2, msg); } catch (AuthenticationException e) { msg = "用户名或密码错误"; return fail(-1, msg); } } else { return success(); } }  @RequestMapping(value = "/api/v1/pub/error/403", method = {RequestMethod.GET, RequestMethod.POST}) JSONObject error403(); @ApiOperation(value = "partyLogin", notes = "第三方登录", httpMethod = "POST") @ApiImplicitParams( { @ApiImplicitParam(name = "openid", value = "openid", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "platform", value = "平台类型,1=QQ,2=微信", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "nickName", value = "昵称", paramType = "query", dataType = "string"), @ApiImplicitParam(name = "headImg", value = "平台类型,1=QQ,2=微信", paramType = "query", dataType = "string") } ) @RequestMapping(value = "/api/v1/pub/party/login", method = {RequestMethod.POST, RequestMethod.GET}) JSONObject partyLogin(
            @RequestParam(value = "openid", required = true) String openid,
            @RequestParam(value = "access_token", required = true) String accessToken,
            @RequestParam(value = "platform", required = true) int platform,
            @RequestParam(value = "nickName", required = true) String nickName,
            @RequestParam(value = "headImg", required = true) String headImg
    ); @ResponseBody @RequestMapping(value = "/api/v1/pub/auth/login", method = RequestMethod.POST) JSONObject login(@RequestBody(required = true) CaptchaUsernamePasswordToken token); @ResponseBody @RequestMapping(value = "/api/v1/pub/auth/logout", method = {RequestMethod.POST, RequestMethod.GET}) void logout(); @ResponseBody @RequestMapping(value = "/api/v1/pub/auth/register", method = RequestMethod.POST) JSONObject register(
            @RequestParam("phone") String phone,
            @RequestParam("password") String password,
            @RequestParam("SMSCode") String smscode);  }