def __call__(self, form, value): exc = colander.Invalid(form, u"Login invalid") #Raised if trouble password = value['password'] email_or_userid = value['email_or_userid'] if '@' in email_or_userid: user = self.context['users'].get_user_by_email(email_or_userid) else: user = self.context['users'].get(email_or_userid, None) if not user: exc['email_or_userid'] = _("Invalid email or UserID") raise exc #Validate password if not hash_method(password) == user.password: exc['password'] = _(u"Wrong password. Remember that passwords are case sensitive.") raise exc
def __call__(self, form, value): exc = colander.Invalid(form, u"Login invalid") # Raised if trouble password = value['password'] email_or_userid = value['email_or_userid'] user = self.context['users'].get_user(email_or_userid) if not user: exc['email_or_userid'] = _("Invalid email or UserID") raise exc # Make sure one is set if not user.password: exc['password'] = _("no_password_set_error", default=u"Password login disabled for this user. " "If you own the account you may request one to " "be set by using the recover password form.") raise exc # Validate password if not hash_method(password, hashed=user.password) == user.password: exc['password'] = _(u"Wrong password. Remember that passwords are case sensitive.") raise exc
def password(self, value): self.__password_hash__ = hash_method(value)
def __call__(self, node, value): if not hash_method(value, hashed=self.context.password) == self.context.password: raise colander.Invalid( node, _("Wrong password. Remember that passwords are case sensitive."))
def password(self, value): if value: self.__password_hash__ = hash_method(value) else: self.__password_hash__ = None