Skip to content

Instantly share code, notes, and snippets.

@fulviodenza
Last active January 18, 2022 12:53
Show Gist options
  • Save fulviodenza/2a2a7d879b0403bfc925a31143481982 to your computer and use it in GitHub Desktop.
Save fulviodenza/2a2a7d879b0403bfc925a31143481982 to your computer and use it in GitHub Desktop.
type (
// App struct provides basic information to connect to the
// Cognito UserPool on AWS.
App struct {
CognitoClient *cognito.CognitoIdentityProvider
UserPoolID string
AppClientID string
AppClientSecret string
Token string
}
User struct {
// Username is the username decided by the user
// at signup time. This field is not required but it could
// be useful to have
Username string `json:"username" validate:"required" db:"username"`
// Password is the password decided by the user
// at signup time. This field is required and no signup
// can work without this.
// To create a secure password, contraints on this field are
// it must contain an uppercase and lowercase letter,
// a special symbol and a number.
Password string `json:"password" validate:"required"`
}
UserForgot struct {
Username string `json:"username" validate:"required"`
}
UserConfirmationCode struct {
ConfirmationCode string `json:"confirmationCode" validate:"required"`
User User `json:"user" validate:"required"`
}
UserRegister struct {
Email string `json:"email" validate:"required" db:"email"`
User User `json:"user" validate:"required"`
}
// OTP is the struct to handle otp verification.
OTP struct {
// Username is the user's username, this is necessary because
// cognito.ConfirmSignUpInput structure requires this field
Username string `json:"username"`
// OTP is the otp code received via email or phone.
OTP string `json:"otp"`
}
// Response is used to handle and return errors from the server.
// These errors could come from AWS or Server side.
Response struct {
Error error `json:"error"`
}
CustomValidator struct {
validator *validator.Validate
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment