60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
// Metro module 13980 (f13981).
|
|
import { Endpoints } from "../../Constants";
|
|
import { HTTP } from "../../_bundle/sendRequest";
|
|
import Dispatcher from "../../Dispatcher";
|
|
export async function fetchAuthSessions() {
|
|
let c27606_1;
|
|
c27606_1 = void 0;
|
|
let c30684_0 = await HTTP.get({
|
|
url: Endpoints.AUTH_SESSIONS,
|
|
rejectWithError: false
|
|
});
|
|
if (c30684_0?.ok && c30684_0.body?.user_sessions != null) {
|
|
Dispatcher.dispatch({
|
|
type: "FETCH_AUTH_SESSIONS_SUCCESS",
|
|
sessions: c30684_0.body.user_sessions
|
|
});
|
|
}
|
|
return c30684_0;
|
|
}
|
|
export function clearAuthSessions() {
|
|
Dispatcher.dispatch({
|
|
type: "FETCH_AUTH_SESSIONS_SUCCESS",
|
|
sessions: []
|
|
});
|
|
}
|
|
export async function logOutSessions(session_id_hashes) {
|
|
let session_id_hashes2;
|
|
let c27607_2;
|
|
let c30685_0, c30685_1;
|
|
L18: {
|
|
c27607_2 = void 0;
|
|
c30685_0 = session_id_hashes;
|
|
c30685_1 = void 0;
|
|
if (Array.isArray(session_id_hashes)) {
|
|
const length = session_id_hashes.length;
|
|
session_id_hashes2 = session_id_hashes;
|
|
if (length === 0) {
|
|
break L18;
|
|
}
|
|
} else {
|
|
session_id_hashes2 = [session_id_hashes];
|
|
c30685_0 = session_id_hashes2;
|
|
}
|
|
c30685_1 = await HTTP.post({
|
|
url: Endpoints.AUTH_SESSIONS_LOGOUT,
|
|
body: {
|
|
session_id_hashes: session_id_hashes2
|
|
},
|
|
rejectWithError: false
|
|
});
|
|
if (c30685_1?.ok) {
|
|
Dispatcher.dispatch({
|
|
type: "LOGOUT_AUTH_SESSIONS_SUCCESS",
|
|
sessionIdHashes: c30685_0
|
|
});
|
|
}
|
|
return c30685_1;
|
|
}
|
|
}
|