How to use the ocflib.account.validators function in ocflib

To help you get started, we’ve selected a few ocflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ocf / ocfweb / ocfweb / login / ocf.py View on Github external
error = None

    return_to = request.GET.get('next')
    if return_to and _valid_return_path(return_to):
        request.session['login_return_path'] = return_to

    if request.method == 'POST':
        form = LoginForm(request.POST)

        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']

            try:
                if (
                        validators.user_exists(username) and not
                        user_is_sorried(username) and
                        utils.password_matches(username, password)
                ):
                    session_login(request, username)
                    return redirect_back(request)
                else:
                    error = (
                        'Authentication failed. Your account may be disabled, '
                        'or you may have typed the wrong username or password.'
                    )
            except ValueError as ex:
                error = 'Authentication failed: {error}'.format(
                    error=str(ex),
                )
    else:
        form = LoginForm()
github ocf / ocfweb / ocfweb / atool / approve / forms.py View on Github external
def clean(self):
        cleaned_data = super(ApproveForm, self).clean()

        # validate password (requires username to check similarity)
        username = cleaned_data.get('username')
        password = cleaned_data.get('password')

        if username and password:
            wrap_validator(validators.validate_password)(username, password)