Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3010272
current-session-subject.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
current-session-subject.js
View Options
"use strict"
;
const
locreq
=
require
(
"locreq"
)(
__dirname
);
const
Promise
=
require
(
"bluebird"
);
const
Response
=
locreq
(
"lib/response/response.js"
);
const
Errors
=
locreq
(
"lib/response/error.js"
);
const
Subject
=
locreq
(
"lib/subject/subject.js"
);
const
SuperContext
=
locreq
(
"lib/super-context.js"
);
const
CurrentSession
=
function
(
app
)
{
this
.
app
=
app
;
};
CurrentSession
.
prototype
=
Object
.
create
(
Subject
.
prototype
);
CurrentSession
.
prototype
.
perform_action
=
function
(
context
,
action_name
,
args
)
{
const
self
=
this
;
switch
(
action_name
)
{
case
"delete"
:
return
self
.
app
.
run_action
(
new
SuperContext
(),
[
"collections"
,
"sessions"
],
"show"
,
{
filter
:
{
"session-id"
:
context
.
session_id
}
}
)
.
each
(
function
(
result
)
{
return
self
.
app
.
run_action
(
new
SuperContext
(),
[
"collections"
,
"sessions"
,
result
.
id
],
"delete"
);
})
.
then
(
function
()
{
return
self
.
app
.
run_action
(
new
SuperContext
(),
[
"collections"
,
"anonymous-sessions"
],
"show"
,
{
filter
:
{
"anonymous-session-id"
:
context
.
anonymous_session_id
,
},
}
);
})
.
each
(
function
(
anon_session
)
{
return
self
.
app
.
run_action
(
new
SuperContext
(),
[
"collections"
,
"anonymous-sessions"
,
anon_session
.
id
],
"delete"
);
})
.
then
(
function
()
{
return
Promise
.
resolve
(
new
Response
(
{},
false
,
"logged_out"
,
"You've been logged out"
)
);
})
.
catch
(
function
(
error
)
{
return
Promise
.
reject
(
new
Errors
.
BadContext
(
"Invalid session id!"
)
);
});
default
:
throw
new
Errors
.
DeveloperError
(
`Unknown action
${
action_name
}
for CurrentSession subject.`
);
}
};
module
.
exports
=
CurrentSession
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, May 7, 19:39 (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
660858
Default Alt Text
current-session-subject.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment