feat: add ability to disable strong password
This commit is contained in:
@@ -168,6 +168,7 @@ func EnvResolver(ctx context.Context) (*model.Env, error) {
|
||||
res.DisableMagicLinkLogin = store[constants.EnvKeyDisableMagicLinkLogin].(bool)
|
||||
res.DisableLoginPage = store[constants.EnvKeyDisableLoginPage].(bool)
|
||||
res.DisableSignUp = store[constants.EnvKeyDisableSignUp].(bool)
|
||||
res.DisableStrongPassword = store[constants.EnvKeyDisableStrongPassword].(bool)
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
@@ -101,6 +101,12 @@ func MetaResolver(ctx context.Context) (*model.Meta, error) {
|
||||
isSignUpDisabled = true
|
||||
}
|
||||
|
||||
isStrongPasswordDisabled, err := memorystore.Provider.GetBoolStoreEnvVariable(constants.EnvKeyDisableStrongPassword)
|
||||
if err != nil {
|
||||
log.Debug("Failed to get Disable Signup from environment variable", err)
|
||||
isSignUpDisabled = true
|
||||
}
|
||||
|
||||
metaInfo := model.Meta{
|
||||
Version: constants.VERSION,
|
||||
ClientID: clientID,
|
||||
@@ -113,6 +119,7 @@ func MetaResolver(ctx context.Context) (*model.Meta, error) {
|
||||
IsEmailVerificationEnabled: !isEmailVerificationDisabled,
|
||||
IsMagicLinkLoginEnabled: !isMagicLinkLoginDisabled,
|
||||
IsSignUpEnabled: !isSignUpDisabled,
|
||||
IsStrongPasswordEnabled: !isStrongPasswordDisabled,
|
||||
}
|
||||
return &metaInfo, nil
|
||||
}
|
||||
|
@@ -50,9 +50,9 @@ func ResetPasswordResolver(ctx context.Context, params model.ResetPasswordInput)
|
||||
return res, fmt.Errorf(`passwords don't match`)
|
||||
}
|
||||
|
||||
if !validators.IsValidPassword(params.Password) {
|
||||
if err := validators.IsValidPassword(params.Password); err != nil {
|
||||
log.Debug("Invalid password")
|
||||
return res, fmt.Errorf(`password is not valid. It needs to be at least 6 characters long and contain at least one number, one uppercase letter, one lowercase letter and one special character`)
|
||||
return res, err
|
||||
}
|
||||
|
||||
// verify if token exists in db
|
||||
|
@@ -58,9 +58,9 @@ func SignupResolver(ctx context.Context, params model.SignUpInput) (*model.AuthR
|
||||
return res, fmt.Errorf(`password and confirm password does not match`)
|
||||
}
|
||||
|
||||
if !validators.IsValidPassword(params.Password) {
|
||||
if err := validators.IsValidPassword(params.Password); err != nil {
|
||||
log.Debug("Invalid password")
|
||||
return res, fmt.Errorf(`password is not valid. It needs to be at least 6 characters long and contain at least one number, one uppercase letter, one lowercase letter and one special character`)
|
||||
return res, err
|
||||
}
|
||||
|
||||
params.Email = strings.ToLower(params.Email)
|
||||
|
Reference in New Issue
Block a user