Skip to content

Commit 78c1592

Browse files
authored
Merge pull request #509 from rainlab/next
[2.x] Exclusivity with OC v3
2 parents 837c81f + 56931b3 commit 78c1592

3 files changed

Lines changed: 17 additions & 31 deletions

File tree

lang/en/lang.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
'activation_tab' => 'Activation',
7575
'signin_tab' => 'Sign in',
7676
'registration_tab' => 'Registration',
77-
'password_policy_tab' => 'Password policy',
77+
'password_policy_tab' => 'Password Policy',
7878
'profile_tab' => 'Profile',
7979
'notifications_tab' => 'Notifications',
8080
'allow_registration' => 'Allow user registration',
@@ -104,8 +104,6 @@
104104
'remember_ask' => 'Ask the user on login',
105105
'min_password_length' => 'Min password length',
106106
'min_password_length_comment' => 'Password length required for users',
107-
'password_policy_hint_warning' => 'October CMS v3 and later',
108-
'password_policy_hint_warning_comment' => 'The password policies below will only work on October CMS v3 and later',
109107
'require_mixed_case' => 'Require mixed case',
110108
'require_mixed_case_comment' => 'Require uppercase and lowercase letters',
111109
'require_number' => 'Require number',

models/User.php

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Carbon\Carbon;
99
use October\Rain\Auth\Models\User as UserBase;
1010
use RainLab\User\Models\Settings as UserSettings;
11+
use Illuminate\Validation\Rules\Password as PasswordRule;
1112
use October\Rain\Auth\AuthException;
1213

1314
class User extends UserBase
@@ -274,31 +275,25 @@ public function beforeValidate()
274275
* Apply rules Settings
275276
*/
276277
$minPasswordLength = Settings::get('min_password_length', static::getMinPasswordLength());
277-
if (class_exists('\Illuminate\Validation\Rules\Password')) {
278-
$passwordRule = \Illuminate\Validation\Rules\Password::min($minPasswordLength);
279-
if (Settings::get('require_mixed_case')) {
280-
$passwordRule->mixedCase();
281-
}
282-
283-
if (Settings::get('require_uncompromised')) {
284-
$passwordRule->uncompromised();
285-
}
286-
287-
if (Settings::get('require_number')) {
288-
$passwordRule->numbers();
289-
}
278+
$passwordRule = PasswordRule::min($minPasswordLength);
279+
if (Settings::get('require_mixed_case')) {
280+
$passwordRule->mixedCase();
281+
}
290282

291-
if (Settings::get('require_symbol')) {
292-
$passwordRule->symbols();
293-
}
283+
if (Settings::get('require_uncompromised')) {
284+
$passwordRule->uncompromised();
285+
}
294286

295-
$this->addValidationRule('password', $passwordRule);
296-
$this->addValidationRule('password_confirmation', $passwordRule);
287+
if (Settings::get('require_number')) {
288+
$passwordRule->numbers();
297289
}
298-
else {
299-
$this->rules['password'] = "required:create|between:$minPasswordLength,255|confirmed";
300-
$this->rules['password_confirmation'] = "required_with:password|between:$minPasswordLength,255";
290+
291+
if (Settings::get('require_symbol')) {
292+
$passwordRule->symbols();
301293
}
294+
295+
$this->addValidationRule('password', $passwordRule);
296+
$this->addValidationRule('password_confirmation', $passwordRule);
302297
}
303298

304299
/**

models/settings/fields.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,6 @@ tabs:
7676
comment: rainlab.user::lang.settings.min_password_length_comment
7777
tab: rainlab.user::lang.settings.password_policy_tab
7878

79-
_october_cms_3:
80-
type: hint
81-
mode: warning
82-
label: rainlab.user::lang.settings.password_policy_hint_warning
83-
comment: rainlab.user::lang.settings.password_policy_hint_warning_comment
84-
tab: rainlab.user::lang.settings.password_policy_tab
85-
8679
# Require Mixed Case
8780
require_mixed_case:
8881
span: left

0 commit comments

Comments
 (0)