11use crate :: auth:: api_key:: ApiKeyService ;
22use crate :: auth:: guards:: AdminGuard ;
3- use crate :: auth:: session:: SessionService ;
43use crate :: auth:: AuthContext ;
54use crate :: models:: auth:: ApiKeyResponse ;
65use async_graphql:: { Context , Object , Result } ;
@@ -12,24 +11,6 @@ pub struct AuthMutations;
1211
1312#[ Object ]
1413impl AuthMutations {
15- /// Logout - invalidate session
16- #[ graphql( name = "logout" ) ]
17- async fn logout ( & self , ctx : & Context < ' _ > , session_token : String ) -> Result < bool > {
18- let pool = ctx. data :: < Arc < PgPool > > ( ) . expect ( "Pool must be in context." ) ;
19- let auth = ctx
20- . data :: < AuthContext > ( )
21- . expect ( "AuthContext must be in context." ) ;
22-
23- if auth. is_authenticated ( ) {
24- SessionService :: delete_session_by_token ( pool. as_ref ( ) , & session_token)
25- . await
26- . map_err ( |e| format ! ( "Failed to logout: {}" , e) ) ?;
27- Ok ( true )
28- } else {
29- Ok ( false )
30- }
31- }
32-
3314 /// Create a new bot with API key (Admin only)
3415 #[ graphql( name = "createBot" , guard = "AdminGuard" ) ]
3516 async fn create_bot ( & self , ctx : & Context < ' _ > , name : String ) -> Result < ApiKeyResponse > {
@@ -50,16 +31,4 @@ impl AuthMutations {
5031
5132 Ok ( ApiKeyResponse { api_key } )
5233 }
53-
54- /// Delete a bot (Admin only)
55- #[ graphql( name = "deleteBot" , guard = "AdminGuard" ) ]
56- async fn delete_bot ( & self , ctx : & Context < ' _ > , api_key_id : i32 ) -> Result < bool > {
57- let pool = ctx. data :: < Arc < PgPool > > ( ) . expect ( "Pool must be in context." ) ;
58-
59- ApiKeyService :: delete_api_key ( pool. as_ref ( ) , api_key_id)
60- . await
61- . map_err ( |e| format ! ( "Failed to delete bot: {}" , e) ) ?;
62-
63- Ok ( true )
64- }
6534}
0 commit comments