Skip to content

Commit

Permalink
Cleans Verification Flow Code
Browse files Browse the repository at this point in the history
  • Loading branch information
Aryan51203 committed Dec 23, 2023
1 parent 645e0e0 commit 34bcdf0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
12 changes: 9 additions & 3 deletions api/verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
}
}
2 changes: 1 addition & 1 deletion pkg/wrapper/kratos/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pkg/wrapper/kratos/registration/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions pkg/wrapper/kratos/verification/verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 34bcdf0

Please sign in to comment.