From 201955c2fbc3fbe7f1a2a483d9c4f0469de5e3d4 Mon Sep 17 00:00:00 2001 From: Daniel Jiang Date: Mon, 20 Apr 2020 12:21:36 +0800 Subject: [PATCH] Enable userExists only when self-registration is turned on. Signed-off-by: Daniel Jiang --- src/core/controllers/base.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/controllers/base.go b/src/core/controllers/base.go index 645f17bf2..d7a960825 100644 --- a/src/core/controllers/base.go +++ b/src/core/controllers/base.go @@ -122,6 +122,14 @@ func (cc *CommonController) LogOut() { // UserExists checks if user exists when user input value in sign in form. func (cc *CommonController) UserExists() { + flag, err := config.SelfRegistration() + if err != nil { + log.Errorf("Failed to get the status of self registration flag, error: %v, disabling user existence check", err) + } + if !flag { + cc.CustomAbort(http.StatusPreconditionFailed, "self registration disabled.") + } + target := cc.GetString("target") value := cc.GetString("value")