From 19cf29b9a46ef71e67dea5baf3c6cf7498b4e404 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 22 Jan 2023 11:04:02 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3?= =?UTF-8?q?ID(username)=E5=A4=89=E6=9B=B4=E6=99=82=E3=81=AB=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E3=82=A4=E3=83=B3ID=E3=81=AE=E3=83=90=E3=83=AA?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=8C=E5=8B=95?= =?UTF-8?q?=E4=BD=9C=E3=81=97=E3=81=AA=E3=81=84=E4=B8=8D=E5=85=B7=E5=90=88?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/User.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Model/User.php b/Model/User.php index 37b2089..3d50c80 100644 --- a/Model/User.php +++ b/Model/User.php @@ -303,7 +303,7 @@ public function beforeValidate($options = array()) { */ protected function _setUsernameValidate() { //ログインID - if (! Hash::get($this->data, 'User.id')) { + if ($this->__isValidateUsernameRequired()) { $this->validate = ValidateMerge::merge($this->validate, array( 'username' => array( 'notBlank' => array( @@ -334,6 +334,34 @@ protected function _setUsernameValidate() { } } +/** + * ログインID(username)のバリデーションを行うかどうか + * + * @return bool + */ + private function __isValidateUsernameRequired() { + if (!Hash::get($this->data, 'User.id')) { + // 新規登録ならば、必ずバリデーションを行う + return true; + } + // 更新時 + if (!isset($this->data['User']['username'])) { + // ログインID(username)がPOSTされてなければバリデーション不要 + return false; + } + $beforeUser = $this->find('first', + [ + 'conditions' => [ + 'id' => $this->data['User']['id'] + ], + 'recursive' => -1, + 'fields' => ['username'] + ] + ); + // ログインID(username)が変更されてなければバリデーション不要。変更されてたらバリデーション必要 + return $beforeUser['User']['username'] !== $this->data['User']['username']; + } + /** * バリデーションのセット(パスワード) * From 22db9af416a471904e913f8a7c424830180874b4 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 24 Feb 2023 17:33:14 +0900 Subject: [PATCH 2/3] =?UTF-8?q?test:=20Github=20Action=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9501566..7cfa881 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,6 +44,7 @@ jobs: MYSQL_VERSION: ${{ matrix.mysql }} MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: cakephp_test + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 From bf48db5af97541d2f19b4c3a90a36c732e8f7e55 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sun, 26 Feb 2023 07:58:46 +0900 Subject: [PATCH 3/3] change: Version number to 3.3.6 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index fa7adc7..9c25013 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.5 +3.3.6