2017-02-13 13 views
1

Gravバージョン1.1.5Gravでユーザー名の検証を無効にするにはどうすればよいですか?

ソースコード内のすべての検証ロジックと検証パターンを削除しましたが、機能しません。ユーザを作成するとエラーが発生します。

エラーメッセージの名前は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}$であるとすることができコメントに@Scuzzyと書かれているように、すべての文字を受け入れるために^(.*)^に変更されました。

セキュリティと可読性が賢明ですが、あなたのウェブサイトに^ = - èöのようなunsernamesを必要としない限り、その正規表現を使用しないことをお勧めします。

Gravを更新するたびにすべての変更を元に戻すことができるため、Gravソースコードに直接触れることを避けることをおすすめします。ソース内の何かを本当に変更したい場合は、プラグインとして作成することを検討してください(個人用であっても)。

+0

'^(。*)^'と '。*'の違いは何ですか?大胆な仕事。 –

関連する問題