2017-02-13 8 views
1

Grav 버전은 1.1입니다.Grav에서 사용자 이름 유효성 검사를 비활성화하는 방법은 무엇입니까?

소스 코드에서 모든 유효성 검사 논리 및 유효성 검사 패턴을 제거했지만 작동하지 않습니다. 사용자를 만들 때 여전히 오류가 발생합니다.

오류 메시지 이름은 USERNAME_NOT_VALID입니다. 모든 소스 코드에서이 코드를 찾아 관련 코드를 삭제하지만 오류가 발생해도 여전히 화면에 표시됩니다. 나는 메시지가 어디서 왔는지 이해하지 못한다.

diff --git a/user/plugins/admin/pages/admin/register.md b/user/plugins/admin/pages/admin/register.md 
index ff0b13b..fc0cf6e 100644 
--- a/user/plugins/admin/pages/admin/register.md 
+++ b/user/plugins/admin/pages/admin/register.md 
@@ -9,7 +9,7 @@ form: 
     validate: 
     required: true 
     message: PLUGIN_LOGIN.USERNAME_NOT_VALID 
-  pattern: '^[a-z0-9_-]{3,16}$' 
+  pattern: '' 

    - name: email 
     type: email 
@@ -27,7 +27,7 @@ form: 
     validate: 
     required: true 
     message: PLUGIN_ADMIN.PASSWORD_VALIDATION_MESSAGE 
-  pattern: '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}' 
+  pattern: '' 

    - name: password2 
     type: password 
@@ -36,7 +36,7 @@ form: 
     validate: 
     required: true 
     message: PLUGIN_ADMIN.PASSWORD_VALIDATION_MESSAGE 
-  pattern: '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}' 
+  pattern: '' 

    - name: fullname 
     type: text 
diff --git a/user/plugins/login/pages/register.md b/user/plugins/login/pages/register.md 
index c4088e2..0391367 100644 
--- a/user/plugins/login/pages/register.md 
+++ b/user/plugins/login/pages/register.md 
@@ -12,7 +12,7 @@ form: 
     validate: 
     required: true 
     message: PLUGIN_LOGIN.USERNAME_NOT_VALID 
-  pattern: '^[a-z0-9_-]{3,16}$' 
+  pattern: '' 

    - 
     name: email 
@@ -31,7 +31,7 @@ form: 
     validate: 
     required: true 
     message: PLUGIN_LOGIN.PASSWORD_VALIDATION_MESSAGE 
-  pattern: '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}' 
+  pattern: '' 

    - 
     name: password2 
@@ -41,7 +41,7 @@ form: 
     validate: 
     required: true 
     message: PLUGIN_LOGIN.PASSWORD_VALIDATION_MESSAGE 
-  pattern: '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}' 
+  pattern: '' 

    buttons: 
     - 
diff --git a/user/plugins/login/pages/reset.md b/user/plugins/login/pages/reset.md 
index e5f82e4..8300d2a 100644 
--- a/user/plugins/login/pages/reset.md 
+++ b/user/plugins/login/pages/reset.md 
@@ -20,7 +20,7 @@ form: 
      validate: 
      required: true 
      message: PLUGIN_LOGIN.PASSWORD_VALIDATION_MESSAGE 
-   pattern: '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}' 
+   pattern: '' 

     - name: token 
      type: hidden 



diff --git a/user/plugins/login/cli/ChangePasswordCommand.php b/user/plugins/login/cli/ChangePasswordCommand.php 
index d15abb7..5bde6cc 100644 
--- a/user/plugins/login/cli/ChangePasswordCommand.php 
+++ b/user/plugins/login/cli/ChangePasswordCommand.php 
@@ -134,9 +134,6 @@ class ChangePasswordCommand extends ConsoleCommand 
    { 
     switch ($type) { 
      case 'user': 
-    if (!preg_match('/^[a-z0-9_-]{3,16}$/', $value)) { 
-     throw new \RuntimeException('Username should be between 3 and 16 characters, including lowercase letters, numbers, underscores, and hyphens. Uppercase letters, spaces, and special characters are not allowed'); 
-    } 
       if (!file_exists(self::getGrav()['locator']->findResource('account://' . $value . YAML_EXT))) { 
        throw new \RuntimeException('Username "' . $value . '" does not exist, please pick another username'); 
       } 
@@ -144,10 +141,6 @@ class ChangePasswordCommand extends ConsoleCommand 
       break; 

      case 'password1': 
-    if (!preg_match('/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/', $value)) { 
-     throw new \RuntimeException('Password must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters'); 
-    } 
- 
       break; 

      case 'password2': 
diff --git a/user/plugins/login/cli/ChangeUserStateCommand.php b/user/plugins/login/cli/ChangeUserStateCommand.php 
index 40f9dc6..90adee6 100644 
--- a/user/plugins/login/cli/ChangeUserStateCommand.php 
+++ b/user/plugins/login/cli/ChangeUserStateCommand.php 
@@ -133,9 +133,6 @@ class ChangeUserStateCommand extends ConsoleCommand 
    { 
     switch ($type) { 
      case 'user': 
-    if (!preg_match('/^[a-z0-9_-]{3,16}$/', $value)) { 
-     throw new \RuntimeException('Username should be between 3 and 16 characters, including lowercase letters, numbers, underscores, and hyphens. Uppercase letters, spaces, and special characters are not allowed'); 
-    } 
       if (!file_exists(self::getGrav()['locator']->findResource('account://' . $value . YAML_EXT))) { 
        throw new \RuntimeException('Username "' . $value . '" does not exist, please pick another username'); 
       } 
diff --git a/user/plugins/login/cli/NewUserCommand.php b/user/plugins/login/cli/NewUserCommand.php 
index 17dbf48..728adda 100644 
--- a/user/plugins/login/cli/NewUserCommand.php 
+++ b/user/plugins/login/cli/NewUserCommand.php 
@@ -237,9 +237,6 @@ class NewUserCommand extends ConsoleCommand 
    { 
     switch ($type) { 
      case 'user': 
-    if (!preg_match('/^[a-z0-9_-]{3,16}$/', $value)) { 
-     throw new \RuntimeException('Username should be between 3 and 16 characters, including lowercase letters, numbers, underscores, and hyphens. Uppercase letters, spaces, and special characters are not allowed'); 
-    } 
       if (file_exists(Grav::instance()['locator']->findResource('account://' . $value . YAML_EXT))) { 
        throw new \RuntimeException('Username "' . $value . '" already exists, please pick another username'); 
       } 
@@ -247,10 +244,6 @@ class NewUserCommand extends ConsoleCommand 
       break; 

      case 'password1': 
-    if (!preg_match('/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/', $value)) { 
-     throw new \RuntimeException('Password must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters'); 
-    } 
- 
       break; 

      case 'password2': 
+2

나는 Grav가 무엇인지 전혀 알지 못한다. 그러나''^ [a-z0-9 _-] {3,16} $ ''을''''''''''' '. *' '그래서 적어도 유효한 패턴이 있습니다. – Scuzzy

답변

1

이미 소스 코드를 건드리지 않고 Grav에 직접 포함 된 변경 방법이 있습니다.

당신은 관리자 패널에 가면이 구성에서, 당신은 각각 "사용자 이름 정규식"와 "비밀번호 정규식"기본적으로

사용자 정의 할 수 있습니다 "고급"이라는 항목이, 사용자 이름 정규식 ^[a-z0-9_-]{3,16}$하고 될 수 있습니다 @ Skuzzy가 주석에 명시한대로 모든 문자를 허용하기 위해 ^(.*)^으로 변경되었습니다.

BTW 보안 및 가독성이 현명한 경우, 귀하의 웹 사이트에서^- - èö와 같은 사용자 이름을 원하지 않는 한 해당 정규 표현식을 사용하지 않는 것이 좋습니다.

Grav를 업데이트 할 때마다 모든 변경 사항을 되돌릴 수 있기 때문에 Grav 소스 코드를 직접 건드리지 않는 것이 좋습니다. 소스에서 무언가를 정말로 변경하고 싶다면 플러그인으로 생성하는 것을 고려해보십시오 (개인용으로도 사용 가능).

+0

'^ (. *) ^'와'. *'의 차이점은 무엇입니까? 대담한 작업. –