fix: typos

This commit is contained in:
Lakhan Samani 2021-08-07 14:11:26 +05:30
parent 52b59a72c5
commit 6a1b484557
16 changed files with 51 additions and 43 deletions

View File

@ -71,7 +71,7 @@ type ComplexityRoot struct {
Login func(childComplexity int, params model.LoginInput) int
Logout func(childComplexity int) int
ResendVerifyEmail func(childComplexity int, params model.ResendVerifyEmailInput) int
ResetPassword func(childComplexity int, params model.ResetPassowrdInput) int
ResetPassword func(childComplexity int, params model.ResetPasswordInput) int
Signup func(childComplexity int, params model.SignUpInput) int
UpdateProfile func(childComplexity int, params model.UpdateProfileInput) int
VerifyEmail func(childComplexity int, params model.VerifyEmailInput) int
@ -120,7 +120,7 @@ type MutationResolver interface {
VerifyEmail(ctx context.Context, params model.VerifyEmailInput) (*model.AuthResponse, error)
ResendVerifyEmail(ctx context.Context, params model.ResendVerifyEmailInput) (*model.Response, error)
ForgotPassword(ctx context.Context, params model.ForgotPasswordInput) (*model.Response, error)
ResetPassword(ctx context.Context, params model.ResetPassowrdInput) (*model.Response, error)
ResetPassword(ctx context.Context, params model.ResetPasswordInput) (*model.Response, error)
DeleteUser(ctx context.Context, params model.DeleteUserInput) (*model.Response, error)
}
type QueryResolver interface {
@ -302,7 +302,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return 0, false
}
return e.complexity.Mutation.ResetPassword(childComplexity, args["params"].(model.ResetPassowrdInput)), true
return e.complexity.Mutation.ResetPassword(childComplexity, args["params"].(model.ResetPasswordInput)), true
case "Mutation.signup":
if e.complexity.Mutation.Signup == nil {
@ -647,7 +647,7 @@ input ForgotPasswordInput {
email: String!
}
input ResetPassowrdInput {
input ResetPasswordInput {
token: String!
password: String!
confirmPassword: String!
@ -665,7 +665,7 @@ type Mutation {
verifyEmail(params: VerifyEmailInput!): AuthResponse!
resendVerifyEmail(params: ResendVerifyEmailInput!): Response!
forgotPassword(params: ForgotPasswordInput!): Response!
resetPassword(params: ResetPassowrdInput!): Response!
resetPassword(params: ResetPasswordInput!): Response!
deleteUser(params: DeleteUserInput!): Response!
}
@ -747,10 +747,10 @@ func (ec *executionContext) field_Mutation_resendVerifyEmail_args(ctx context.Co
func (ec *executionContext) field_Mutation_resetPassword_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
var err error
args := map[string]interface{}{}
var arg0 model.ResetPassowrdInput
var arg0 model.ResetPasswordInput
if tmp, ok := rawArgs["params"]; ok {
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("params"))
arg0, err = ec.unmarshalNResetPassowrdInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResetPassowrdInput(ctx, tmp)
arg0, err = ec.unmarshalNResetPasswordInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResetPasswordInput(ctx, tmp)
if err != nil {
return nil, err
}
@ -1615,7 +1615,7 @@ func (ec *executionContext) _Mutation_resetPassword(ctx context.Context, field g
fc.Args = args
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return ec.resolvers.Mutation().ResetPassword(rctx, args["params"].(model.ResetPassowrdInput))
return ec.resolvers.Mutation().ResetPassword(rctx, args["params"].(model.ResetPasswordInput))
})
if err != nil {
ec.Error(ctx, err)
@ -3651,8 +3651,8 @@ func (ec *executionContext) unmarshalInputResendVerifyEmailInput(ctx context.Con
return it, nil
}
func (ec *executionContext) unmarshalInputResetPassowrdInput(ctx context.Context, obj interface{}) (model.ResetPassowrdInput, error) {
var it model.ResetPassowrdInput
func (ec *executionContext) unmarshalInputResetPasswordInput(ctx context.Context, obj interface{}) (model.ResetPasswordInput, error) {
var it model.ResetPasswordInput
var asMap = obj.(map[string]interface{})
for k, v := range asMap {
@ -4571,8 +4571,8 @@ func (ec *executionContext) unmarshalNResendVerifyEmailInput2githubᚗcomᚋauth
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) unmarshalNResetPassowrdInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResetPassowrdInput(ctx context.Context, v interface{}) (model.ResetPassowrdInput, error) {
res, err := ec.unmarshalInputResetPassowrdInput(ctx, v)
func (ec *executionContext) unmarshalNResetPasswordInput2githubᚗcomᚋauthorizerdevᚋauthorizerᚋserverᚋgraphᚋmodelᚐResetPasswordInput(ctx context.Context, v interface{}) (model.ResetPasswordInput, error) {
res, err := ec.unmarshalInputResetPasswordInput(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
}

View File

@ -41,7 +41,7 @@ type ResendVerifyEmailInput struct {
Email string `json:"email"`
}
type ResetPassowrdInput struct {
type ResetPasswordInput struct {
Token string `json:"token"`
Password string `json:"password"`
ConfirmPassword string `json:"confirmPassword"`

View File

@ -87,7 +87,7 @@ input ForgotPasswordInput {
email: String!
}
input ResetPassowrdInput {
input ResetPasswordInput {
token: String!
password: String!
confirmPassword: String!
@ -105,7 +105,7 @@ type Mutation {
verifyEmail(params: VerifyEmailInput!): AuthResponse!
resendVerifyEmail(params: ResendVerifyEmailInput!): Response!
forgotPassword(params: ForgotPasswordInput!): Response!
resetPassword(params: ResetPassowrdInput!): Response!
resetPassword(params: ResetPasswordInput!): Response!
deleteUser(params: DeleteUserInput!): Response!
}

View File

@ -39,7 +39,7 @@ func (r *mutationResolver) ForgotPassword(ctx context.Context, params model.Forg
return resolvers.ForgotPassword(ctx, params)
}
func (r *mutationResolver) ResetPassword(ctx context.Context, params model.ResetPassowrdInput) (*model.Response, error) {
func (r *mutationResolver) ResetPassword(ctx context.Context, params model.ResetPasswordInput) (*model.Response, error) {
return resolvers.ResetPassword(ctx, params)
}

View File

@ -63,7 +63,7 @@ func processGoogleUserInfo(code string, c *gin.Context) error {
}
user, _ = db.Mgr.SaveUser(user)
userIdStr := fmt.Sprintf("%d", user.ID)
userIdStr := fmt.Sprintf("%v", user.ID)
refreshToken, _, _ := utils.CreateAuthToken(utils.UserAuthInfo{
ID: userIdStr,
Email: user.Email,
@ -139,7 +139,7 @@ func processGithubUserInfo(code string, c *gin.Context) error {
}
user, _ = db.Mgr.SaveUser(user)
userIdStr := fmt.Sprintf("%d", user.ID)
userIdStr := fmt.Sprintf("%v", user.ID)
refreshToken, _, _ := utils.CreateAuthToken(utils.UserAuthInfo{
ID: userIdStr,
Email: user.Email,

View File

@ -49,7 +49,7 @@ func VerifyEmailHandler() gin.HandlerFunc {
// delete from verification table
db.Mgr.DeleteToken(claim.Email)
userIdStr := fmt.Sprintf("%d", user.ID)
userIdStr := fmt.Sprintf("%v", user.ID)
refreshToken, _, _ := utils.CreateAuthToken(utils.UserAuthInfo{
ID: userIdStr,
Email: user.Email,

View File

@ -7,6 +7,7 @@ import (
"github.com/authorizerdev/authorizer/server/db"
"github.com/authorizerdev/authorizer/server/graph/model"
"github.com/authorizerdev/authorizer/server/session"
"github.com/authorizerdev/authorizer/server/utils"
)
@ -21,6 +22,13 @@ func DeleteUser(ctx context.Context, params model.DeleteUserInput) (*model.Respo
return res, fmt.Errorf("unauthorized")
}
user, err := db.Mgr.GetUserByEmail(params.Email)
if err != nil {
return res, err
}
session.DeleteToken(fmt.Sprintf("%x", user.ID))
err = db.Mgr.DeleteUser(params.Email)
if err != nil {
log.Println("Err:", err)

View File

@ -46,7 +46,7 @@ func Login(ctx context.Context, params model.LoginInput) (*model.AuthResponse, e
log.Println("Compare password error:", err)
return res, fmt.Errorf(`invalid password`)
}
userIdStr := fmt.Sprintf("%d", user.ID)
userIdStr := fmt.Sprintf("%v", user.ID)
refreshToken, _, _ := utils.CreateAuthToken(utils.UserAuthInfo{
ID: userIdStr,
Email: user.Email,

View File

@ -38,7 +38,7 @@ func Profile(ctx context.Context) (*model.User, error) {
return res, err
}
userIdStr := fmt.Sprintf("%d", user.ID)
userIdStr := fmt.Sprintf("%v", user.ID)
res = &model.User{
ID: userIdStr,

View File

@ -12,7 +12,7 @@ import (
"github.com/authorizerdev/authorizer/server/utils"
)
func ResetPassword(ctx context.Context, params model.ResetPassowrdInput) (*model.Response, error) {
func ResetPassword(ctx context.Context, params model.ResetPasswordInput) (*model.Response, error) {
var res *model.Response
if constants.DISABLE_BASIC_AUTHENTICATION == "true" {
return res, fmt.Errorf(`basic authentication is disabled for this instance`)

View File

@ -68,7 +68,7 @@ func Signup(ctx context.Context, params model.SignUpInput) (*model.AuthResponse,
if err != nil {
return res, err
}
userIdStr := fmt.Sprintf("%d", user.ID)
userIdStr := fmt.Sprintf("%v", user.ID)
userToReturn := &model.User{
ID: userIdStr,
Email: user.Email,

View File

@ -32,7 +32,7 @@ func Token(ctx context.Context) (*model.AuthResponse, error) {
return res, err
}
userIdStr := fmt.Sprintf("%d", user.ID)
userIdStr := fmt.Sprintf("%v", user.ID)
sessionToken := session.GetToken(userIdStr)

View File

@ -97,7 +97,7 @@ func UpdateProfile(ctx context.Context, params model.UpdateProfileInput) (*model
return res, fmt.Errorf("user with this email address already exists")
}
session.DeleteToken(fmt.Sprintf("%d", user.ID))
session.DeleteToken(fmt.Sprintf("%v", user.ID))
utils.DeleteCookie(gc)
user.Email = newEmail

View File

@ -25,16 +25,16 @@ func Users(ctx context.Context) ([]*model.User, error) {
return res, err
}
for _, user := range users {
for i := 0; i < len(users); i++ {
res = append(res, &model.User{
ID: fmt.Sprintf("%d", user.ID),
Email: user.Email,
SignupMethod: user.SignupMethod,
FirstName: &user.FirstName,
LastName: &user.LastName,
EmailVerifiedAt: &user.EmailVerifiedAt,
CreatedAt: &user.CreatedAt,
UpdatedAt: &user.UpdatedAt,
ID: fmt.Sprintf("%v", users[i].ID),
Email: users[i].Email,
SignupMethod: users[i].SignupMethod,
FirstName: &users[i].FirstName,
LastName: &users[i].LastName,
EmailVerifiedAt: &users[i].EmailVerifiedAt,
CreatedAt: &users[i].CreatedAt,
UpdatedAt: &users[i].UpdatedAt,
})
}

View File

@ -25,15 +25,15 @@ func VerificationRequests(ctx context.Context) ([]*model.VerificationRequest, er
return res, err
}
for _, verificationRequest := range verificationRequests {
for i := 0; i < len(verificationRequests); i++ {
res = append(res, &model.VerificationRequest{
ID: fmt.Sprintf("%d", verificationRequest.ID),
Email: &verificationRequest.Email,
Token: &verificationRequest.Token,
Identifier: &verificationRequest.Identifier,
Expires: &verificationRequest.ExpiresAt,
CreatedAt: &verificationRequest.CreatedAt,
UpdatedAt: &verificationRequest.UpdatedAt,
ID: fmt.Sprintf("%v", verificationRequests[i].ID),
Email: &verificationRequests[i].Email,
Token: &verificationRequests[i].Token,
Identifier: &verificationRequests[i].Identifier,
Expires: &verificationRequests[i].ExpiresAt,
CreatedAt: &verificationRequests[i].CreatedAt,
UpdatedAt: &verificationRequests[i].UpdatedAt,
})
}

View File

@ -40,7 +40,7 @@ func VerifyEmail(ctx context.Context, params model.VerifyEmailInput) (*model.Aut
// delete from verification table
db.Mgr.DeleteToken(claim.Email)
userIdStr := fmt.Sprintf("%d", user.ID)
userIdStr := fmt.Sprintf("%v", user.ID)
refreshToken, _, _ := utils.CreateAuthToken(utils.UserAuthInfo{
ID: userIdStr,
Email: user.Email,