Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions v2/attackprotectionsuite/backend-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 == "" {
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion v2/src/plugins/codeTypeChecking/goEnv/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions v2/src/plugins/codeTypeChecking/goEnv/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion v2/src/plugins/codeTypeChecking/pythonEnv/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
Expand Down