99 "github.com/localstack/lstk/internal/api"
1010 "github.com/localstack/lstk/internal/env"
1111 "github.com/localstack/lstk/internal/output"
12- "github.com/pkg/browser"
1312)
1413
1514type LoginProvider interface {
@@ -35,41 +34,23 @@ func (l *loginProvider) Login(ctx context.Context) (string, error) {
3534 }
3635
3736 authURL := fmt .Sprintf ("%s/auth/request/%s" , getWebAppURL (), authReq .ID )
38- output .EmitLog (l .sink , fmt . Sprintf ( "Visit: %s" , authURL ) )
39- output .EmitLog (l .sink , fmt . Sprintf ( "Verification code: %s" , authReq . Code ) )
37+ output .EmitLog (l .sink , "1. Open this link in your browser and sign in" )
38+ output .EmitHighlightLog (l .sink , authURL )
4039
41- // Ask whether to open the browser; ENTER or Y accepts (default yes), N skips
42- browserCh := make (chan output.InputResponse , 1 )
43- output .EmitUserInputRequest (l .sink , output.UserInputRequestEvent {
44- Prompt : "Open browser now?" ,
45- Options : []output.InputOption {{Key : "y" , Label : "Y" }, {Key : "n" , Label : "n" }},
46- ResponseCh : browserCh ,
47- })
48-
49- select {
50- case resp := <- browserCh :
51- if resp .Cancelled {
52- return "" , context .Canceled
53- }
54- if resp .SelectedKey != "n" {
55- if err := browser .OpenURL (authURL ); err != nil {
56- output .EmitLog (l .sink , fmt .Sprintf ("Warning: Failed to open browser: %v" , err ))
57- }
58- }
59- case <- ctx .Done ():
60- return "" , ctx .Err ()
61- }
40+ output .EmitLog (l .sink , "" )
41+ output .EmitLog (l .sink , "2. Enter this one-time verification code after you log in" )
42+ output .EmitHighlightLog (l .sink , authReq .Code )
43+ output .EmitLog (l .sink , "" )
6244
63- // Wait for the user to complete authentication in the browser
64- enterCh := make (chan output.InputResponse , 1 )
45+ responseCh := make (chan output.InputResponse , 1 )
6546 output .EmitUserInputRequest (l .sink , output.UserInputRequestEvent {
66- Prompt : "Waiting for authentication" ,
67- Options : []output.InputOption {{Key : "enter" , Label : "Press ENTER when complete " }},
68- ResponseCh : enterCh ,
47+ Prompt : "Waiting for authentication... (Press ENTER when complete) " ,
48+ Options : []output.InputOption {{Key : "enter" , Label : "" }},
49+ ResponseCh : responseCh ,
6950 })
7051
7152 select {
72- case resp := <- enterCh :
53+ case resp := <- responseCh :
7354 if resp .Cancelled {
7455 return "" , context .Canceled
7556 }
0 commit comments