Skip to content

Commit

Permalink
Merge pull request #2 from keitaroinc/cleapup2
Browse files Browse the repository at this point in the history
dynamic chars and readme fix
  • Loading branch information
blagojabozinovski authored Aug 22, 2023
2 parents 530aaa6 + de0aefb commit 536df35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ To install ckanext-password-policy:

2. Clone the source and install it on the virtualenv

```
git clone https://github.com/Keitaro/ckanext-password-policy.git
cd ckanext-password-policy
pip install -e .
pip install -r requirements.txt
pip install -r requirements.txt
```

3. Add `password-policy` to the `ckan.plugins` setting in your CKAN
3. Add `password_policy` to the `ckan.plugins` setting in your CKAN
config file (by default the config file is located at
`/etc/ckan/default/ckan.ini`).

Expand Down
6 changes: 4 additions & 2 deletions ckanext/password_policy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import ckan.lib.navl.dictization_functions as df
import ckanext.password_policy.helpers as h
from six import string_types
from ckan.common import _
from ckan.common import _, config


Missing = df.Missing
missing = df.missing

password_length = config.get('ckan.password_policy.password_length')


def user_custom_password_validator(key, data, errors, context):
value = data[key]
Expand All @@ -22,7 +24,7 @@ def user_custom_password_validator(key, data, errors, context):
elif value == '':
pass
elif not valid_pass['password_ok']:
errors[('password',)].append(_('Your password must be 12 characters or '
errors[('password',)].append(_(f'Your password must be {password_length} characters or '
'longer and contain uppercase, lowercase, '
'digit and special character'))

Expand Down
4 changes: 3 additions & 1 deletion ckanext/password_policy/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ class PerformResetView_(PerformResetView):
def _get_form_password(self):
password1 = request.form.get(u'password1')
password2 = request.form.get(u'password2')

password_length = config.get('ckan.password_policy.password_length')

valid_pass = helper.custom_password_check(password1)
if valid_pass['password_ok']==False:
raise ValueError(
_(u'Your password must be 12 characters or '
_(f"u'Your password must be {password_length} characters or '"
u'longer and contain uppercase, lowercase, '
u'digit and special character'))
elif password1 != password2:
Expand Down

0 comments on commit 536df35

Please sign in to comment.