Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1262519
session.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
700 B
Referenced Files
None
Subscribers
None
session.ts
View Options
import
Router
=
require
(
"@koa/router"
);
import
parseBody
from
"../parse-body"
;
const
sessionRouter
=
new
Router
();
sessionRouter
.
post
(
"/"
,
parseBody
(),
async
(
ctx
)
=>
{
const
username
=
ctx
.
request
.
body
.
username
;
const
password
=
ctx
.
request
.
body
.
password
;
const
session_id
=
await
ctx
.
$app
.
collections
.
sessions
.
login
(
username
,
password
);
ctx
.
body
=
{
status
:
"logged in!"
};
ctx
.
status
=
201
;
const
config
=
ctx
.
$app
.
ConfigManager
.
get
(
"www-server"
);
const
cookie_name
=
config
[
"session-cookie-name"
];
ctx
.
cookies
.
set
(
cookie_name
,
session_id
,
{
maxAge
:
1000
*
60
*
60
*
24
*
7
,
secure
:
ctx
.
request
.
protocol
===
"https"
,
overwrite
:
true
,
});
});
export
default
sessionRouter
;
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jan 24, 10:37 (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
601595
Default Alt Text
session.ts (700 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment