From 34bcdf022934a9a7dcb51c73f0a31decd550e8e5 Mon Sep 17 00:00:00 2001 From: Aryan Singh Date: Sun, 24 Dec 2023 01:49:44 +0530 Subject: [PATCH] Cleans Verification Flow Code --- api/verification.go | 12 +++++++++--- pkg/wrapper/kratos/login/login.go | 2 +- pkg/wrapper/kratos/registration/registration.go | 2 +- pkg/wrapper/kratos/verification/verification.go | 3 --- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/api/verification.go b/api/verification.go index ce07792..eb025cc 100644 --- a/api/verification.go +++ b/api/verification.go @@ -73,7 +73,13 @@ func HandlePostVerificationFlow(c *gin.Context) { return } - c.JSON(http.StatusOK, gin.H{ - "message": "Account Verification Successful", - }) + if t.Token == "" { + c.JSON(http.StatusOK, gin.H{ + "message": "Account Verification Mail Sent", + }) + } else { + c.JSON(http.StatusOK, gin.H{ + "message": "Account Verification Successful", + }) + } } diff --git a/pkg/wrapper/kratos/login/login.go b/pkg/wrapper/kratos/login/login.go index 0cf9baf..bc2fa5c 100644 --- a/pkg/wrapper/kratos/login/login.go +++ b/pkg/wrapper/kratos/login/login.go @@ -10,7 +10,7 @@ import ( func InitializeLoginFlowWrapper(aal string, cookie string) (string, string, string, error) { refresh := false // bool | Refresh a login session If set to true, this will refresh an existing login session by asking the user to sign in again. This will reset the authenticated_at time of the session. (optional) - returnTo := "http://127.0.0.1:4455/ping" // string | The URL to return the browser to after the flow was completed. (optional) + returnTo := "http://localhost:4455/ping" // string | The URL to return the browser to after the flow was completed. (optional) apiClient := client.NewAPIClient(config.KratosClientConfig) diff --git a/pkg/wrapper/kratos/registration/registration.go b/pkg/wrapper/kratos/registration/registration.go index c88bfc4..39771f1 100644 --- a/pkg/wrapper/kratos/registration/registration.go +++ b/pkg/wrapper/kratos/registration/registration.go @@ -12,7 +12,7 @@ import ( ) func InitializeRegistrationFlowWrapper() (string, string, string, error) { - returnTo := "http://127.0.0.1:4455/ping" + returnTo := "http://localhost:4455/ping" apiClient := client.NewAPIClient(config.KratosClientConfig) resp, r, err := apiClient.V0alpha2Api.InitializeSelfServiceRegistrationFlowForBrowsers(context.Background()).ReturnTo(returnTo).Execute() diff --git a/pkg/wrapper/kratos/verification/verification.go b/pkg/wrapper/kratos/verification/verification.go index f3bf8f5..4b697ab 100644 --- a/pkg/wrapper/kratos/verification/verification.go +++ b/pkg/wrapper/kratos/verification/verification.go @@ -22,7 +22,6 @@ func InitializeVerificationFlowWrapper() (string, string, string, error) { var csrf_token string for _, node := range resp.Ui.Nodes { - fmt.Println(node.Attributes.UiNodeInputAttributes) if node.Attributes.UiNodeInputAttributes.Name == "csrf_token" { csrf_token_interface := node.Attributes.UiNodeInputAttributes.Value csrf_token, _ = csrf_token_interface.(string) @@ -46,8 +45,6 @@ func SubmitVerificationFlowWrapper(cookie string, flowID string, csrfToken strin _, r, err := apiClient.V0alpha2Api.SubmitSelfServiceVerificationFlow(context.Background()).Flow(flowID).Token(token).SubmitSelfServiceVerificationFlowBody(submitFlowBody).Cookie(cookie).Execute() - fmt.Println(r) - if err != nil { fmt.Fprintf(os.Stderr, "Error when calling `V0alpha2Api.SubmitSelfServiceVerificationFlow``: %v\n", err) fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)