Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1263371
logout.redirect.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
841 B
Referenced Files
None
Subscribers
None
logout.redirect.ts
View Options
import
type
{
Context
}
from
"koa"
;
import
{
Mountable
}
from
"@sealcode/sealgen"
;
import
type
Router
from
"@koa/router"
;
export
const
actionName
=
"Logout"
;
export
default
new
(
class
LogoutRedirect
extends
Mountable
{
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async
canAccess
(
_
:
Context
)
{
return
{
canAccess
:
true
,
message
:
""
};
}
mount
(
router
:
Router
,
path
:
string
)
{
router
.
get
(
path
,
async
(
ctx
)
=>
{
try
{
const
session_id
=
ctx
.
cookies
.
get
(
"sealious-session"
);
if
(
session_id
)
{
await
ctx
.
$app
.
collections
.
sessions
.
logout
(
new
ctx
.
$app
.
SuperContext
(),
session_id
);
ctx
.
status
=
302
;
ctx
.
redirect
(
"/"
);
}
else
{
ctx
.
status
=
302
;
ctx
.
redirect
(
"/"
);
}
}
catch
(
error
)
{
console
.
error
(
"Error during logout:"
,
error
);
}
});
}
})();
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jan 24, 16:50 (1 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
598733
Default Alt Text
logout.redirect.ts (841 B)
Attached To
Mode
rPLAY Sealious playground
Attached
Detach File
Event Timeline
Log In to Comment