fix: import cycle issues

This commit is contained in:
Lakhan Samani
2022-05-30 11:54:16 +05:30
parent 1146468a03
commit 7e3bd6a721
37 changed files with 349 additions and 239 deletions

View File

@@ -14,8 +14,10 @@ import (
"github.com/authorizerdev/authorizer/server/email"
"github.com/authorizerdev/authorizer/server/graph/model"
"github.com/authorizerdev/authorizer/server/memorystore"
"github.com/authorizerdev/authorizer/server/parsers"
"github.com/authorizerdev/authorizer/server/token"
"github.com/authorizerdev/authorizer/server/utils"
"github.com/authorizerdev/authorizer/server/validators"
)
// UpdateUserResolver is a resolver for update user mutation
@@ -97,7 +99,7 @@ func UpdateUserResolver(ctx context.Context, params model.UpdateUserInput) (*mod
if params.Email != nil && user.Email != *params.Email {
// check if valid email
if !utils.IsValidEmail(*params.Email) {
if !validators.IsValidEmail(*params.Email) {
log.Debug("Invalid email: ", *params.Email)
return res, fmt.Errorf("invalid email address")
}
@@ -113,7 +115,7 @@ func UpdateUserResolver(ctx context.Context, params model.UpdateUserInput) (*mod
// TODO figure out how to do this
go memorystore.Provider.DeleteAllUserSession(user.ID)
hostname := utils.GetHost(gc)
hostname := parsers.GetHost(gc)
user.Email = newEmail
user.EmailVerifiedAt = nil
// insert verification request
@@ -123,7 +125,7 @@ func UpdateUserResolver(ctx context.Context, params model.UpdateUserInput) (*mod
return res, err
}
verificationType := constants.VerificationTypeUpdateEmail
redirectURL := utils.GetAppURL(gc)
redirectURL := parsers.GetAppURL(gc)
verificationToken, err := token.CreateVerificationToken(newEmail, verificationType, hostname, nonceHash, redirectURL)
if err != nil {
log.Debug("Failed to create verification token: ", err)
@@ -163,12 +165,12 @@ func UpdateUserResolver(ctx context.Context, params model.UpdateUserInput) (*mod
log.Debug("Error getting protected roles: ", err)
}
if !utils.IsValidRoles(inputRoles, append([]string{}, append(roles, protectedRoles...)...)) {
if !validators.IsValidRoles(inputRoles, append([]string{}, append(roles, protectedRoles...)...)) {
log.Debug("Invalid roles: ", params.Roles)
return res, fmt.Errorf("invalid list of roles")
}
if !utils.IsStringArrayEqual(inputRoles, currentRoles) {
if !validators.IsStringArrayEqual(inputRoles, currentRoles) {
rolesToSave = strings.Join(inputRoles, ",")
}