This repository was archived by the owner on Aug 29, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +41
-8
lines changed
Expand file tree Collapse file tree 5 files changed +41
-8
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,4 @@ namespace Microsoft.Graph.Cli.Authentication;
44
55interface ILoginService {
66 Task LoginAsync ( string [ ] scopes ) ;
7-
8- void Logout ( ) ;
97}
Original file line number Diff line number Diff line change @@ -11,12 +11,6 @@ public async Task LoginAsync(string[] scopes) {
1111 await this . SaveSessionAsync ( record ) ;
1212 }
1313
14- public void Logout ( ) {
15- if ( File . Exists ( Constants . AuthRecordPath ) ) {
16- File . Delete ( Constants . AuthRecordPath ) ;
17- }
18- }
19-
2014 protected abstract Task < AuthenticationRecord > DoLoginAsync ( string [ ] scopes ) ;
2115
2216 public async Task SaveSessionAsync ( AuthenticationRecord record ) {
Original file line number Diff line number Diff line change 1+ using System . IO ;
2+ using Microsoft . Graph . Cli . Utils ;
3+
4+ namespace Microsoft . Graph . Cli . Authentication ;
5+
6+ public class LogoutService {
7+ public void Logout ( ) {
8+ if ( File . Exists ( Constants . AuthRecordPath ) ) {
9+ File . Delete ( Constants . AuthRecordPath ) ;
10+ }
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ using Microsoft . Graph . Cli . Authentication ;
2+ using Microsoft . Graph . Cli . Utils ;
3+ using System . CommandLine ;
4+ using System . CommandLine . Invocation ;
5+
6+ namespace Microsoft . Graph . Cli . Commands . Authentication ;
7+
8+ class LogoutCommand
9+ {
10+ private readonly LogoutService logoutService ;
11+
12+ public LogoutCommand ( LogoutService logoutService ) {
13+ this . logoutService = logoutService ;
14+ }
15+
16+ public Command Build ( ) {
17+ var logoutCommand = new Command ( "logout" , "Logout by deleting the stored session used in commands" ) ;
18+
19+ logoutCommand . Handler = CommandHandler . Create ( ( ) =>
20+ {
21+ this . logoutService . Logout ( ) ;
22+ } ) ;
23+
24+ return logoutCommand ;
25+ }
26+ }
Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ static async Task<int> Main(string[] args) {
2525
2626 var loginCommand = new LoginCommand ( authServiceFactory ) ;
2727 rootCommand . AddCommand ( loginCommand . Build ( ) ) ;
28+
29+ var logoutCommand = new LogoutCommand ( new LogoutService ( ) ) ;
30+ rootCommand . AddCommand ( logoutCommand . Build ( ) ) ;
2831 return await rootCommand . InvokeAsync ( args ) ;
2932 }
3033 }
You can’t perform that action at this time.
0 commit comments