This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree 2 files changed +17
-9
lines changed 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -19,11 +19,15 @@ public async Task<IActionResult> Sessions()
19
19
return View ( "Sessions" , model ) ;
20
20
}
21
21
22
- [ HttpGet ( "sessions-logout" ) ]
23
- public async Task < IActionResult > LogoutAllOtherSessions ( )
22
+ [ HttpPost ( "sessions" ) ]
23
+ [ ValidateAntiForgeryToken ]
24
+ public async Task < IActionResult > LogoutAllOtherSessions ( [ FromForm ] string ? action )
24
25
{
25
- //TODO: protect with anti forgery token
26
- _ = await api . Frontend . DisableMyOtherSessionsAsync ( cookie : Request . Headers . Cookie ) ;
26
+ if ( action == "invokeSessions" )
27
+ {
28
+ _ = await api . Frontend . DisableMyOtherSessionsAsync ( cookie : Request . Headers . Cookie ) ;
29
+ }
30
+
27
31
return Redirect ( "sessions" ) ;
28
32
}
29
33
}
Original file line number Diff line number Diff line change 1
1
@using UAParser
2
+ @using Microsoft .AspNetCore .Components .Web
2
3
@model SessionsModel
3
4
@{
4
5
Layout = " _NavbarLayout" ;
96
97
}
97
98
else
98
99
{
99
- <div class =" buttons" >
100
- <a class =" button is-warning" href =" sessions-logout" >
101
- @CustomTranslator.Get( " sessions.logoutOtherSessions" )
102
- </a >
103
- </div >
100
+ <form action =" /sessions" method =" post" >
101
+ @Html.AntiForgeryToken()
102
+ <div class =" buttons" >
103
+ <button type =" submit" class =" button is-warning" name =" action" value =" invokeSessions" >
104
+ @CustomTranslator.Get( " sessions.logoutOtherSessions" )
105
+ </button >
106
+ </div >
107
+ </form >
104
108
<table class =" table is-fullwidth" >
105
109
<thead >
106
110
<tr >
You can’t perform that action at this time.
0 commit comments