diff --git a/v2/attackprotectionsuite/backend-setup.mdx b/v2/attackprotectionsuite/backend-setup.mdx index 746555ddd..563016a2a 100644 --- a/v2/attackprotectionsuite/backend-setup.mdx +++ b/v2/attackprotectionsuite/backend-setup.mdx @@ -594,6 +594,7 @@ import ( "encoding/hex" "encoding/json" "net/http" + "errors" "github.com/supertokens/supertokens-golang/recipe/emailpassword" "github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels" @@ -777,13 +778,16 @@ func main() { email := "" password := "" for _, field := range formFields { - if field.ID == "email" { - email = field.Value - break - } - if field.ID == "password" { - password = field.Value - break + if field.ID == "email" || field.ID == "password" { + valueAsString, asStrOk := field.Value.(string) + if !asStrOk { + return epmodels.SignUpPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + if field.ID == "email" { + email = valueAsString + } else { + password = valueAsString + } } } bruteForceConfig := getBruteForceConfig(email, ip, actionType) @@ -841,13 +845,16 @@ func main() { email := "" password := "" for _, field := range formFields { - if field.ID == "email" { - email = field.Value - break - } - if field.ID == "password" { - password = field.Value - break + if field.ID == "email" || field.ID == "password" { + valueAsString, asStrOk := field.Value.(string) + if !asStrOk { + return epmodels.SignInPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + if field.ID == "email" { + email = valueAsString + } else { + password = valueAsString + } } } bruteForceConfig := getBruteForceConfig(email, ip, actionType) @@ -905,8 +912,11 @@ func main() { email := "" for _, field := range formFields { if field.ID == "email" { - email = field.Value - break + valueAsString, asStrOk := field.Value.(string) + if !asStrOk { + return epmodels.GeneratePasswordResetTokenPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + email = valueAsString } } bruteForceConfig := getBruteForceConfig(email, ip, actionType) diff --git a/v2/emailpassword/advanced-customizations/apis-override/custom-response/general-error.mdx b/v2/emailpassword/advanced-customizations/apis-override/custom-response/general-error.mdx index bbf83347c..7ed597bd6 100644 --- a/v2/emailpassword/advanced-customizations/apis-override/custom-response/general-error.mdx +++ b/v2/emailpassword/advanced-customizations/apis-override/custom-response/general-error.mdx @@ -67,6 +67,8 @@ function emailNotAllowed(email: string) { ```go import ( + "errors" + "github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels" "github.com/supertokens/supertokens-golang/recipe/emailpassword" "github.com/supertokens/supertokens-golang/supertokens" @@ -82,7 +84,11 @@ func main() { email := "" for _, v := range formFields { if v.ID == "email" { - email = v.Value + valueAsString, asStrOk := v.Value.(string) + if !asStrOk { + return epmodels.SignUpPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + email = valueAsString } } if emailNotAllowed(email) { diff --git a/v2/emailpassword/common-customizations/handling-signup-success.mdx b/v2/emailpassword/common-customizations/handling-signup-success.mdx index 31e8e2db6..0fb8b6d35 100644 --- a/v2/emailpassword/common-customizations/handling-signup-success.mdx +++ b/v2/emailpassword/common-customizations/handling-signup-success.mdx @@ -382,6 +382,7 @@ SuperTokens.init({ ```go import ( "fmt" + "errors" "github.com/supertokens/supertokens-golang/recipe/emailpassword" "github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels" @@ -417,7 +418,11 @@ func main() { name := "" for _, field := range formFields { if field.ID == "name" { - name = field.Value + valueAsString, asStrOk := field.Value.(string) + if !asStrOk { + return epmodels.SignUpPOSTResponse{}, errors.New("name should be a string") + } + name = valueAsString } } diff --git a/v2/emailpassword/common-customizations/username-password/emailpassword-changes.mdx b/v2/emailpassword/common-customizations/username-password/emailpassword-changes.mdx index 07e984e0b..5869e796a 100644 --- a/v2/emailpassword/common-customizations/username-password/emailpassword-changes.mdx +++ b/v2/emailpassword/common-customizations/username-password/emailpassword-changes.mdx @@ -453,6 +453,8 @@ SuperTokens.init({ ```go import ( + "errors" + "github.com/supertokens/supertokens-golang/recipe/emailpassword" "github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels" "github.com/supertokens/supertokens-golang/supertokens" @@ -502,7 +504,11 @@ func main() { actualEmail := "" for _, field := range formFields { if field.ID == "email" { - actualEmail = field.Value + valueAsString, asStrOk := field.Value.(string) + if !asStrOk { + return epmodels.SignUpPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + actualEmail = valueAsString } } if actualEmail == "" { @@ -1003,6 +1009,7 @@ SuperTokens.init({ ```go import ( "regexp" + "errors" "github.com/supertokens/supertokens-golang/recipe/emailpassword" "github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels" @@ -1069,7 +1076,11 @@ func main() { emailOrUsername := "" for _, field := range formFields { if field.ID == "email" { - emailOrUsername = field.Value + valueAsString, asStrOk := field.Value.(string) + if !asStrOk { + return epmodels.GeneratePasswordResetTokenPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + emailOrUsername = valueAsString } } if isInputEmail(emailOrUsername) { @@ -1104,7 +1115,11 @@ func main() { username := "" for _, field := range formFields { if field.ID == "email" { - username = field.Value + valueAsString, asStrOk := field.Value.(string) + if !asStrOk { + return epmodels.GeneratePasswordResetTokenPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + username = valueAsString } } supertokensUser, err := emailpassword.GetUserByEmail(tenantId, username) diff --git a/v2/emailpassword/migration/account-creation/ep-migration-without-password-hash.mdx b/v2/emailpassword/migration/account-creation/ep-migration-without-password-hash.mdx index 678b00a4c..b694af292 100644 --- a/v2/emailpassword/migration/account-creation/ep-migration-without-password-hash.mdx +++ b/v2/emailpassword/migration/account-creation/ep-migration-without-password-hash.mdx @@ -139,6 +139,8 @@ init( ```go import ( + "errors" + "github.com/supertokens/supertokens-golang/recipe/emailpassword" "github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels" "github.com/supertokens/supertokens-golang/supertokens" @@ -159,7 +161,11 @@ func main() { email := "" for _, formField := range formFields { if formField.ID == "email" { - email = formField.Value + valueAsString, asStrOk := formField.Value.(string) + if !asStrOk { + return epmodels.SignUpPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + email = valueAsString } } // Check if the user signing in exists in the external provider @@ -428,11 +434,16 @@ func main() { email := "" password := "" for _, formField := range formFields { - if formField.ID == "email" { - email = formField.Value - } - if formField.ID == "password" { - password = formField.Value + if formField.ID == "email" || formField.ID == "password" { + valueAsString, asStrOk := formField.Value.(string) + if !asStrOk { + return epmodels.SignInPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + if formField.ID == "email" { + email = valueAsString + } else { + password = valueAsString + } } } // Check if an email-password user with the input email exists in SuperTokens @@ -768,7 +779,11 @@ func main() { var email *string = nil for _, field := range formFields { if field.ID == "email" { - email = &field.Value + valueAsString, asStrOk := field.Value.(string) + if !asStrOk { + return epmodels.GeneratePasswordResetTokenPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + email = &valueAsString } } @@ -1351,11 +1366,16 @@ func main() { email := "" password := "" for _, formField := range formFields { - if formField.ID == "email" { - email = formField.Value - } - if formField.ID == "password" { - password = formField.Value + if formField.ID == "email" || formField.ID == "password" { + valueAsString, asStrOk := formField.Value.(string) + if !asStrOk { + return epmodels.SignInPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + if formField.ID == "email" { + email = valueAsString + } else { + password = valueAsString + } } } // Check if an email-password user with the input email exists in SuperTokens diff --git a/v2/src/plugins/codeTypeChecking/goEnv/go.mod b/v2/src/plugins/codeTypeChecking/goEnv/go.mod index 565ce9305..2d12c54f6 100644 --- a/v2/src/plugins/codeTypeChecking/goEnv/go.mod +++ b/v2/src/plugins/codeTypeChecking/goEnv/go.mod @@ -9,7 +9,7 @@ require ( github.com/go-chi/cors v1.2.1 github.com/gorilla/handlers v1.5.1 github.com/gorilla/mux v1.8.0 - github.com/supertokens/supertokens-golang v0.24.0 + github.com/supertokens/supertokens-golang v0.25.0 ) require ( diff --git a/v2/src/plugins/codeTypeChecking/goEnv/go.sum b/v2/src/plugins/codeTypeChecking/goEnv/go.sum index 2008c56b8..e87a83529 100644 --- a/v2/src/plugins/codeTypeChecking/goEnv/go.sum +++ b/v2/src/plugins/codeTypeChecking/goEnv/go.sum @@ -95,8 +95,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/supertokens/supertokens-golang v0.24.0 h1:/Y4PS72K7DHplMSskIsOBnvzpOppzFau/Y6q2X/5VeE= -github.com/supertokens/supertokens-golang v0.24.0/go.mod h1:/n6zQ9461RscnnWB4Y4bWwzhPivnj8w79j/doqkLOs8= +github.com/supertokens/supertokens-golang v0.25.0 h1:yTWBKD8tZFe6sYSQ5h1IYTsH/c3UQlqyqRvSFGVXx/o= +github.com/supertokens/supertokens-golang v0.25.0/go.mod h1:/n6zQ9461RscnnWB4Y4bWwzhPivnj8w79j/doqkLOs8= github.com/twilio/twilio-go v0.26.0 h1:wFW4oTe3/LKt6bvByP7eio8JsjtaLHjMQKOUEzQry7U= github.com/twilio/twilio-go v0.26.0/go.mod h1:lz62Hopu4vicpQ056H5TJ0JE4AP0rS3sQ35/ejmgOwE= github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo= diff --git a/v2/src/plugins/codeTypeChecking/pythonEnv/requirements.txt b/v2/src/plugins/codeTypeChecking/pythonEnv/requirements.txt index 0148110d1..c4fa3e4c4 100644 --- a/v2/src/plugins/codeTypeChecking/pythonEnv/requirements.txt +++ b/v2/src/plugins/codeTypeChecking/pythonEnv/requirements.txt @@ -72,7 +72,7 @@ six==1.16.0 sniffio==1.3.0 sqlparse==0.4.2 starlette==0.14.2 -supertokens-python==0.24.0 +supertokens-python==0.24.3 tldextract==3.1.0 toml==0.10.2 tomli==2.0.1 diff --git a/v2/thirdpartyemailpassword/advanced-customizations/apis-override/custom-response/general-error.mdx b/v2/thirdpartyemailpassword/advanced-customizations/apis-override/custom-response/general-error.mdx index 896ebed93..6233bcf6a 100644 --- a/v2/thirdpartyemailpassword/advanced-customizations/apis-override/custom-response/general-error.mdx +++ b/v2/thirdpartyemailpassword/advanced-customizations/apis-override/custom-response/general-error.mdx @@ -67,6 +67,8 @@ function emailNotAllowed(email: string) { ```go import ( + "errors" + "github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels" "github.com/supertokens/supertokens-golang/recipe/emailpassword" "github.com/supertokens/supertokens-golang/supertokens" @@ -82,7 +84,11 @@ func main() { email := "" for _, v := range formFields { if v.ID == "email" { - email = v.Value + valueAsString, asStrOk := v.Value.(string) + if !asStrOk { + return epmodels.SignUpPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + email = valueAsString } } if emailNotAllowed(email) { diff --git a/v2/thirdpartyemailpassword/common-customizations/handling-signinup-success.mdx b/v2/thirdpartyemailpassword/common-customizations/handling-signinup-success.mdx index de08042e7..ddf3f14f2 100644 --- a/v2/thirdpartyemailpassword/common-customizations/handling-signinup-success.mdx +++ b/v2/thirdpartyemailpassword/common-customizations/handling-signinup-success.mdx @@ -561,6 +561,7 @@ SuperTokens.init({ ```go import ( "fmt" + "errors" "github.com/supertokens/supertokens-golang/recipe/emailpassword" "github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels" @@ -596,7 +597,11 @@ func main() { name := "" for _, field := range formFields { if field.ID == "name" { - name = field.Value + valueAsString, asStrOk := field.Value.(string) + if !asStrOk { + return epmodels.SignUpPOSTResponse{}, errors.New("name should be a string") + } + name = valueAsString } } diff --git a/v2/thirdpartyemailpassword/migration/account-creation/ep-migration-without-password-hash.mdx b/v2/thirdpartyemailpassword/migration/account-creation/ep-migration-without-password-hash.mdx index 8e555693d..6b5a356dd 100644 --- a/v2/thirdpartyemailpassword/migration/account-creation/ep-migration-without-password-hash.mdx +++ b/v2/thirdpartyemailpassword/migration/account-creation/ep-migration-without-password-hash.mdx @@ -139,6 +139,8 @@ init( ```go import ( + "errors" + "github.com/supertokens/supertokens-golang/recipe/emailpassword" "github.com/supertokens/supertokens-golang/recipe/emailpassword/epmodels" "github.com/supertokens/supertokens-golang/supertokens" @@ -159,7 +161,11 @@ func main() { email := "" for _, formField := range formFields { if formField.ID == "email" { - email = formField.Value + valueAsString, asStrOk := formField.Value.(string) + if !asStrOk { + return epmodels.SignUpPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + email = valueAsString } } // Check if the user signing in exists in the external provider @@ -428,11 +434,16 @@ func main() { email := "" password := "" for _, formField := range formFields { - if formField.ID == "email" { - email = formField.Value - } - if formField.ID == "password" { - password = formField.Value + if formField.ID == "email" || formField.ID == "password" { + valueAsString, asStrOk := formField.Value.(string) + if !asStrOk { + return epmodels.SignInPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + if formField.ID == "email" { + email = valueAsString + } else { + password = valueAsString + } } } // Check if an email-password user with the input email exists in SuperTokens @@ -768,7 +779,11 @@ func main() { var email *string = nil for _, field := range formFields { if field.ID == "email" { - email = &field.Value + valueAsString, asStrOk := field.Value.(string) + if !asStrOk { + return epmodels.GeneratePasswordResetTokenPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + email = &valueAsString } } @@ -1351,11 +1366,16 @@ func main() { email := "" password := "" for _, formField := range formFields { - if formField.ID == "email" { - email = formField.Value - } - if formField.ID == "password" { - password = formField.Value + if formField.ID == "email" || formField.ID == "password" { + valueAsString, asStrOk := formField.Value.(string) + if !asStrOk { + return epmodels.SignInPOSTResponse{}, errors.New("Should never come here as we check the type during validation") + } + if formField.ID == "email" { + email = valueAsString + } else { + password = valueAsString + } } } // Check if an email-password user with the input email exists in SuperTokens