File tree Expand file tree Collapse file tree
TrafficEscape2.0/Controllers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using Microsoft . AspNetCore . Mvc ;
22using TrafficEscape2 . _0 . Handlers ;
33using TrafficEscape2 . _0 . Models ;
4+ using TrafficEscape2 . _0 . Services . Interfaces ;
45
56namespace TrafficEscape2 . _0 . Controllers
67{
@@ -9,10 +10,12 @@ namespace TrafficEscape2._0.Controllers
910 public class LoginController : ControllerBase
1011 {
1112 private readonly ILoginHandler loginHandler ;
13+ private readonly IAuthorizationService authorizationService ;
1214
13- public LoginController ( ILoginHandler loginHandler )
15+ public LoginController ( ILoginHandler loginHandler , IAuthorizationService authorizationService )
1416 {
1517 this . loginHandler = loginHandler ;
18+ this . authorizationService = authorizationService ;
1619 }
1720
1821 [ HttpPost ]
@@ -21,5 +24,13 @@ public async Task<IActionResult> Login(UserLoginRequest loginRequest)
2124 LoginResponse response = await this . loginHandler . Login ( loginRequest ) ;
2225 return Ok ( response ) ;
2326 }
27+
28+ [ HttpGet ( "validateToken" ) ]
29+ [ AuthRequired ]
30+ public IActionResult ValidateToken ( String userId )
31+ {
32+ bool valid = this . authorizationService . IsValid ( userId , HttpContext ) ;
33+ return Ok ( valid ) ;
34+ }
2435 }
2536}
You can’t perform that action at this time.
0 commit comments