Commit 886e8e16 authored by Quxl's avatar Quxl

x

parent 385053b5
...@@ -51,7 +51,7 @@ public interface OAuthApi { ...@@ -51,7 +51,7 @@ public interface OAuthApi {
} }
} }
default OAuthToken getOAuthToken() { default OAuthToken doLogin() {
try { try {
HttpServletRequest request = this.getHttpServletRequest(); HttpServletRequest request = this.getHttpServletRequest();
HttpSession session = request.getSession(); HttpSession session = request.getSession();
...@@ -83,7 +83,14 @@ public interface OAuthApi { ...@@ -83,7 +83,14 @@ public interface OAuthApi {
} }
} }
default OAuthToken refreshOAuthToken() { default void doLogout() {
HttpServletRequest request = this.getHttpServletRequest();
HttpSession session = request.getSession();
session.removeAttribute(OAUTH_TOKEN_SESSION);
session.invalidate();
}
default OAuthToken refresh() {
try { try {
HttpServletRequest request = this.getHttpServletRequest(); HttpServletRequest request = this.getHttpServletRequest();
HttpSession session = request.getSession(); HttpSession session = request.getSession();
...@@ -124,7 +131,7 @@ public interface OAuthApi { ...@@ -124,7 +131,7 @@ public interface OAuthApi {
String resBody = resourceResponse.getBody(); String resBody = resourceResponse.getBody();
return resBody; return resBody;
} catch (OAuthProblemException e) { } catch (OAuthProblemException e) {
this.refreshOAuthToken(); this.refresh();
return doRequest(method, url, parameters); return doRequest(method, url, parameters);
} catch (Exception e) { } catch (Exception e) {
throw new OAuthApiException(e.getMessage(), e); throw new OAuthApiException(e.getMessage(), e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment