def validate_python(self, value, state): from rhodecode.lib.auth import authenticate password = value["password"] username = value["username"] if not authenticate(username, password): user = User.get_by_username(username) if user and user.active is False: log.warning("user %s is disabled" % username) msg = M(self, "disabled_account", state) raise formencode.Invalid(msg, value, state, error_dict=dict(username=msg)) else: log.warning("user %s failed to authenticate" % username) msg = M(self, "invalid_username", state) msg2 = M(self, "invalid_password", state) raise formencode.Invalid(msg, value, state, error_dict=dict(username=msg, password=msg2))
def validate_python(self, value, state): password = value['password'] username = value['username'] user = User.get_by_username(username) if authenticate(username, password): return value else: if user and user.active is False: log.warning('user %s is disabled', username) raise formencode.Invalid(self.message('disabled_account', state=State_obj), value, state, error_dict=self.e_dict_disable) else: log.warning('user %s not authenticated', username) raise formencode.Invalid(self.message('invalid_password', state=State_obj), value, state, error_dict=self.e_dict)
def validate_python(self, value, state): from rhodecode.lib.auth import authenticate password = value['password'] username = value['username'] if not authenticate(username, password): user = User.get_by_username(username) if user and not user.active: log.warning('user %s is disabled' % username) msg = M(self, 'disabled_account', state) raise formencode.Invalid(msg, value, state, error_dict=dict(username=msg) ) else: log.warning('user %s failed to authenticate' % username) msg = M(self, 'invalid_username', state) msg2 = M(self, 'invalid_password', state) raise formencode.Invalid(msg, value, state, error_dict=dict(username=msg, password=msg2) )
def validate_python(self, value, state): password = value['password'] username = value['username'] user = User.get_by_username(username) if authenticate(username, password): return value else: if user and user.active is False: log.warning('user %s is disabled' % username) raise formencode.Invalid( self.message('disabled_account', state=State_obj), value, state, error_dict=self.e_dict_disable ) else: log.warning('user %s failed to authenticate' % username) raise formencode.Invalid( self.message('invalid_password', state=State_obj), value, state, error_dict=self.e_dict )