From d364b288545194999efc538d6691149376c7dda9 Mon Sep 17 00:00:00 2001 From: celestix <73958752+celestix@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:33:39 +0530 Subject: [PATCH] fix invalid implementation of RetryPassword hook RetryPassword hook of conservator is supposed to ask call AskPassword but it was calling AskCode instead in web auth example as well as basic conservator. --- authConversation.go | 2 +- authHelper.go | 2 +- examples/auth-using-api-base/web/webauth.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/authConversation.go b/authConversation.go index 2069cf9..6694163 100644 --- a/authConversation.go +++ b/authConversation.go @@ -48,5 +48,5 @@ func (b *basicConservator) RetryPassword(trialsLeft int) (string, error) { fmt.Println("The 2FA Code you just entered seems to be incorrect,") fmt.Println("Attempts Left:", trialsLeft) fmt.Println("Please try again....") - return b.AskCode() + return b.AskPassword() } diff --git a/authHelper.go b/authHelper.go index 93c2f15..3c0ab05 100644 --- a/authHelper.go +++ b/authHelper.go @@ -64,7 +64,7 @@ func authFlow(ctx context.Context, client *auth.Client, conversator AuthConversa sentCode, err := client.SendCode(ctx, phone, f.Options) if err != nil { - return errors.Wrap(err, "send code") + return err } switch s := sentCode.(type) { case *tg.AuthSentCode: diff --git a/examples/auth-using-api-base/web/webauth.go b/examples/auth-using-api-base/web/webauth.go index 2b035c2..1df6331 100644 --- a/examples/auth-using-api-base/web/webauth.go +++ b/examples/auth-using-api-base/web/webauth.go @@ -2,6 +2,7 @@ package web import ( "fmt" + "github.com/celestix/gotgproto" ) @@ -39,7 +40,7 @@ func (w *webAuth) RetryPassword(attemptsLeft int) (string, error) { fmt.Println("The 2FA Code you just entered seems to be incorrect,") fmt.Println("Attempts Left:", attemptsLeft) fmt.Println("Please try again.... ") - return w.AskCode() + return w.AskPassword() } func ReceivePhone(phone string) {