sc-sc - 云代码空间
——
上一篇我根据框架中OAuth2.0的使用总结,画了一个根据用户名+密码实现OAuth2.0的登录认证的流程图,今天我们看一下logout的流程:
/** * 用户注销 * @param accessToken * @return */ @RequestMapping(value = "/user/logout", method = RequestMethod.POST) public ResponseVO userLogout(@RequestHeader(value = "accessToken", required = true) String accessToken, @RequestHeader(value = "userId", required = true) Long userId) throws Exception{ OauthAccessToken oauthAccessToken = userMgrService.getOauthAccessToken(accessToken); if(null == oauthAccessToken){ return UserResponseCode.buildEnumResponseVO(UserResponseCode.RESPONSE_CODE_OAUTH_ACCESSTOKEN_EMPTY, null); } //刪除OauthToken记录 boolean result = userMgrService.revokeOauthToken(oauthAccessToken); if(result){ return UserResponseCode.buildEnumResponseVO(UserResponseCode.RESPONSE_RETURN_CODE_SUCCESS, null); } return UserResponseCode.buildEnumResponseVO(UserResponseCode.RESPONSE_CODE_SYSTEM_ERROR, null); }