fix: add disable basic auth check in resolvers
This commit is contained in:
parent
0a2efe048b
commit
2795ad299d
|
@ -7,6 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/constants"
|
||||||
"github.com/authorizerdev/authorizer/server/db"
|
"github.com/authorizerdev/authorizer/server/db"
|
||||||
"github.com/authorizerdev/authorizer/server/enum"
|
"github.com/authorizerdev/authorizer/server/enum"
|
||||||
"github.com/authorizerdev/authorizer/server/graph/model"
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||||
|
@ -15,6 +16,10 @@ import (
|
||||||
|
|
||||||
func ForgotPassword(ctx context.Context, params model.ForgotPasswordInput) (*model.Response, error) {
|
func ForgotPassword(ctx context.Context, params model.ForgotPasswordInput) (*model.Response, error) {
|
||||||
var res *model.Response
|
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)
|
params.Email = strings.ToLower(params.Email)
|
||||||
|
|
||||||
if !utils.IsValidEmail(params.Email) {
|
if !utils.IsValidEmail(params.Email) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/constants"
|
||||||
"github.com/authorizerdev/authorizer/server/db"
|
"github.com/authorizerdev/authorizer/server/db"
|
||||||
"github.com/authorizerdev/authorizer/server/enum"
|
"github.com/authorizerdev/authorizer/server/enum"
|
||||||
"github.com/authorizerdev/authorizer/server/graph/model"
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||||
|
@ -21,6 +22,10 @@ func Login(ctx context.Context, params model.LoginInput) (*model.LoginResponse,
|
||||||
return res, err
|
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)
|
params.Email = strings.ToLower(params.Email)
|
||||||
user, err := db.Mgr.GetUserByEmail(params.Email)
|
user, err := db.Mgr.GetUserByEmail(params.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/constants"
|
||||||
"github.com/authorizerdev/authorizer/server/db"
|
"github.com/authorizerdev/authorizer/server/db"
|
||||||
"github.com/authorizerdev/authorizer/server/graph/model"
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||||
"github.com/authorizerdev/authorizer/server/utils"
|
"github.com/authorizerdev/authorizer/server/utils"
|
||||||
|
@ -11,6 +12,9 @@ import (
|
||||||
|
|
||||||
func ResetPassword(ctx context.Context, params model.ResetPassowrdInput) (*model.Response, error) {
|
func ResetPassword(ctx context.Context, params model.ResetPassowrdInput) (*model.Response, error) {
|
||||||
var res *model.Response
|
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 {
|
if params.Password != params.ConfirmPassword {
|
||||||
return res, fmt.Errorf(`passwords don't match`)
|
return res, fmt.Errorf(`passwords don't match`)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/authorizerdev/authorizer/server/constants"
|
||||||
"github.com/authorizerdev/authorizer/server/db"
|
"github.com/authorizerdev/authorizer/server/db"
|
||||||
"github.com/authorizerdev/authorizer/server/enum"
|
"github.com/authorizerdev/authorizer/server/enum"
|
||||||
"github.com/authorizerdev/authorizer/server/graph/model"
|
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||||
|
@ -15,6 +16,10 @@ import (
|
||||||
|
|
||||||
func Signup(ctx context.Context, params model.SignUpInput) (*model.Response, error) {
|
func Signup(ctx context.Context, params model.SignUpInput) (*model.Response, error) {
|
||||||
var res *model.Response
|
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 {
|
if params.ConfirmPassword != params.Password {
|
||||||
return res, fmt.Errorf(`passowrd and confirm password does not match`)
|
return res, fmt.Errorf(`passowrd and confirm password does not match`)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user