implementing frontend password policy check

This commit is contained in:
kakwa 2015-07-01 08:50:50 +02:00
parent 04e28f10b1
commit ac7661731c
2 changed files with 11 additions and 2 deletions

View File

@ -765,11 +765,20 @@ class LdapCherry(object):
return self.temp_searchuser.render(searchresult = res, attrs_list = attrs_list, is_admin=is_admin)
@cherrypy.expose
def checkppolicy(self, password):
def checkppolicy(self, **params):
""" search user page """
keys = params.keys()
if len(keys) != 1:
cherrypy.response.status = 403
return "bad argument"
password = params[keys[0]]
self._check_auth(must_admin=False)
is_admin = self._check_admin()
ret = self._checkppolicy(password)
if ret['match']:
cherrypy.response.status = 200
else:
cherrypy.response.status = 400
return json.dumps(ret, separators=(',',':'))
@cherrypy.expose

View File

@ -57,7 +57,7 @@ for a in sorted(attributes.keys(), key=lambda attr: attributes[attr]['weight']):
%endfor
</select>
% elif attr['type'] == 'password':
<input type="password" class="form-control" name="attr.${a}1" id="${a}1" placeholder="${attr['description']}" ${required}>
<input type="password" class="form-control" data-error="Don't meet password policy" data-remote="/checkppolicy" name="attr.${a}1" id="${a}1" placeholder="${attr['description']}" ${required}>
<span class="input-group-addon" id="basic-addon1">Retype ${attr['display_name']}</span>
<input type="password" class="form-control" data-match="#${a}1" data-match-error="Passwords don't match" name="attr.${a}2" id="#${a}2" placeholder="Confirm" ${required}>
% endif