mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
Session Token Invalidation on Logout
This commit is contained in:
parent
e666dca403
commit
ee0ab2ac9e
@ -260,19 +260,22 @@ public class ApiServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
if (apiAuthenticator.getAPIType() == APIAuthenticationType.LOGOUT_API) {
|
||||
if (session != null) {
|
||||
final Long userId = (Long) session.getAttribute("userid");
|
||||
final Account account = (Account) session.getAttribute("accountobj");
|
||||
Long accountId = null;
|
||||
if (account != null) {
|
||||
accountId = account.getId();
|
||||
}
|
||||
auditTrailSb.insert(0, "(userId=" + userId + " accountId=" + accountId + " sessionId=" + session.getId() + ")");
|
||||
if (userId != null) {
|
||||
apiServer.logoutUser(userId);
|
||||
}
|
||||
invalidateHttpSession(session, "invalidating session after logout call");
|
||||
if (session == null) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Session not found for the logout process.");
|
||||
}
|
||||
|
||||
final Long userId = (Long) session.getAttribute("userid");
|
||||
final Account account = (Account) session.getAttribute("accountobj");
|
||||
Long accountId = null;
|
||||
if (account != null) {
|
||||
accountId = account.getId();
|
||||
}
|
||||
auditTrailSb.insert(0, "(userId=" + userId + " accountId=" + accountId + " sessionId=" + session.getId() + ")");
|
||||
if (userId != null) {
|
||||
apiServer.logoutUser(userId);
|
||||
}
|
||||
invalidateHttpSession(session, "invalidating session after logout call");
|
||||
|
||||
final Cookie[] cookies = req.getCookies();
|
||||
if (cookies != null) {
|
||||
for (final Cookie cookie : cookies) {
|
||||
|
||||
@ -65,7 +65,6 @@ export function login (arg) {
|
||||
}
|
||||
|
||||
export function logout () {
|
||||
sourceToken.cancel()
|
||||
message.destroy()
|
||||
notification.destroy()
|
||||
return api('logout')
|
||||
|
||||
@ -24,6 +24,7 @@ import router from '@/router'
|
||||
import store from '@/store'
|
||||
import { oauthlogin, login, logout, api } from '@/api'
|
||||
import { i18n } from '@/locales'
|
||||
import { sourceToken } from '@/utils/request'
|
||||
|
||||
import {
|
||||
ACCESS_TOKEN,
|
||||
@ -374,11 +375,6 @@ const user = {
|
||||
cloudianUrl = state.cloudian.url + 'logout.htm?redirect=' + encodeURIComponent(window.location.href)
|
||||
}
|
||||
|
||||
Object.keys(Cookies.get()).forEach(cookieName => {
|
||||
Cookies.remove(cookieName)
|
||||
Cookies.remove(cookieName, { path: '/client' })
|
||||
})
|
||||
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_APIS', {})
|
||||
commit('SET_PROJECT', {})
|
||||
@ -406,6 +402,11 @@ const user = {
|
||||
}
|
||||
}).catch(() => {
|
||||
resolve()
|
||||
}).finally(() => {
|
||||
Object.keys(Cookies.get()).forEach(cookieName => {
|
||||
Cookies.remove(cookieName)
|
||||
Cookies.remove(cookieName, { path: '/client' })
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user