예제 #1
0
        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))
예제 #2
0
파일: forms.py 프로젝트: q210/rhodecode
    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)
예제 #3
0
        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)
                    )
예제 #4
0
파일: forms.py 프로젝트: elfixit/rhodecode
    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
                )