summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2009-10-16 02:22:39 -0600
committerJason Gerard DeRose <jderose@redhat.com>2009-10-18 00:35:05 -0600
commitb35849b47d1018fef339ea63e364b29c848bd26d (patch)
tree650c6200d0b3847dec68ef233241f36a13a36199 /ipalib
parenta3a0c0ae339d2f963287fc88847aac7e2249e30f (diff)
downloadfreeipa-b35849b47d1018fef339ea63e364b29c848bd26d.tar.gz
freeipa-b35849b47d1018fef339ea63e364b29c848bd26d.tar.xz
freeipa-b35849b47d1018fef339ea63e364b29c848bd26d.zip
Change Password param so (password, confirm_password) can be passed to _convert_scalar()
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/errors.py9
-rw-r--r--ipalib/parameters.py9
2 files changed, 18 insertions, 0 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py
index fb82062ab..1c358cd6f 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -736,6 +736,15 @@ class NoSuchNamespaceError(InvocationError):
format = _('api has no such namespace: %(name)r')
+class PasswordMismatch(InvocationError):
+ """
+ **3011** Raise when password and password confirmation don't match.
+ """
+
+ errno = 3011
+ format = _('Passwords do not match')
+
+
##############################################################################
# 4000 - 4999: Execution errors
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index bf6588ba3..819a158ff 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -35,6 +35,7 @@ from util import make_repr
from request import ugettext
from plugable import ReadOnly, lock, check_name
from errors import ConversionError, RequirementError, ValidationError
+from errors import PasswordMismatch
from constants import NULLS, TYPE_ERROR, CALLABLE_ERROR
import csv
@@ -1145,6 +1146,14 @@ class Password(Str):
A parameter for passwords (stored in the ``unicode`` type).
"""
+ def _convert_scalar(self, value, index=None):
+ if isinstance(value, (tuple, list)) and len(value) == 2:
+ (p1, p2) = value
+ if p1 != p2:
+ raise PasswordMismatch(name=self.name, index=index)
+ value = p1
+ return super(Password, self)._convert_scalar(value, index)
+
class Enum(Param):
"""