fix: add disable basic auth check in resolvers

This commit is contained in:
Lakhan Samani 2021-07-28 15:22:11 +05:30
parent 0a2efe048b
commit 2795ad299d
4 changed files with 19 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
"strings"
"time"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/db"
"github.com/authorizerdev/authorizer/server/enum"
"github.com/authorizerdev/authorizer/server/graph/model"
@ -15,6 +16,10 @@ import (
func ForgotPassword(ctx context.Context, params model.ForgotPasswordInput) (*model.Response, error) {
var res *model.Response
if constants.DISABLE_BASIC_AUTHENTICATION == "true" {
return res, fmt.Errorf(`basic authentication is disabled for this instance`)
}
params.Email = strings.ToLower(params.Email)
if !utils.IsValidEmail(params.Email) {

View File

@ -6,6 +6,7 @@ import (
"log"
"strings"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/db"
"github.com/authorizerdev/authorizer/server/enum"
"github.com/authorizerdev/authorizer/server/graph/model"
@ -21,6 +22,10 @@ func Login(ctx context.Context, params model.LoginInput) (*model.LoginResponse,
return res, err
}
if constants.DISABLE_BASIC_AUTHENTICATION == "true" {
return res, fmt.Errorf(`basic authentication is disabled for this instance`)
}
params.Email = strings.ToLower(params.Email)
user, err := db.Mgr.GetUserByEmail(params.Email)
if err != nil {

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/db"
"github.com/authorizerdev/authorizer/server/graph/model"
"github.com/authorizerdev/authorizer/server/utils"
@ -11,6 +12,9 @@ import (
func ResetPassword(ctx context.Context, params model.ResetPassowrdInput) (*model.Response, error) {
var res *model.Response
if constants.DISABLE_BASIC_AUTHENTICATION == "true" {
return res, fmt.Errorf(`basic authentication is disabled for this instance`)
}
if params.Password != params.ConfirmPassword {
return res, fmt.Errorf(`passwords don't match`)

View File

@ -7,6 +7,7 @@ import (
"strings"
"time"
"github.com/authorizerdev/authorizer/server/constants"
"github.com/authorizerdev/authorizer/server/db"
"github.com/authorizerdev/authorizer/server/enum"
"github.com/authorizerdev/authorizer/server/graph/model"
@ -15,6 +16,10 @@ import (
func Signup(ctx context.Context, params model.SignUpInput) (*model.Response, error) {
var res *model.Response
if constants.DISABLE_BASIC_AUTHENTICATION == "true" {
return res, fmt.Errorf(`basic authentication is disabled for this instance`)
}
if params.ConfirmPassword != params.Password {
return res, fmt.Errorf(`passowrd and confirm password does not match`)
}