Exemplo n.º 1
0
 def test_validate_invalid_password(self, user):
     """Invalid password."""
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'Invalid password' in form.password.errors
Exemplo n.º 2
0
 def test_validate_success(self, user):
     """Login successful."""
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is True
     assert form.user == user
Exemplo n.º 3
0
 def test_validate_invalid_password(self, user):
     """Invalid password."""
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'Invalid password' in form.password.errors
Exemplo n.º 4
0
 def test_validate_success(self, user):
     """Login successful."""
     user.set_password('example')
     user.save()
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is True
     assert form.user == user
Exemplo n.º 5
0
def login():
    # Skip login form on forced SSO
    if request.method == "GET" and current_app.config["OAUTH_SKIP_LOGIN"]:
        if not request.args.get('local') and oauth_type():
            return redirect(url_for(oauth_type() + '.login'))
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user, remember=True)
            if not form.user.active:
                flash(
                    'This user account is under review. ' +
                    'Please update your profile and contact the organizing ' +
                    'team to access all functions of this platform.',
                    'warning')
            else:
                flash("You are logged in! Time to make something awesome ≧◡≦",
                      'success')
            redirect_url = request.args.get("next") or url_for("public.home")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template("public/login.html",
                           form=form,
                           oauth_type=oauth_type())
Exemplo n.º 6
0
 def test_validate_inactive_user(self, user):
     """Inactive user."""
     user.active = False
     user.set_password('example')
     user.save()
     # Correct username and password, but user is not activated
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'User not activated' in form.username.errors
Exemplo n.º 7
0
 def test_validate_inactive_user(self, user):
     """Inactive user."""
     user.active = False
     user.set_password('example')
     user.save()
     # Correct username and password, but user is not activated
     form = LoginForm(username=user.username, password='******')
     assert form.validate() is False
     assert 'User not activated' in form.username.errors
Exemplo n.º 8
0
 def test_validate_inactive_user(self, user, testapp):
     """Inactive user."""
     user.active = False
     user.set_password('example')
     user.save()
     # Correct username and password, but user is not activated
     form = LoginForm(username=user.username, password='******')
     # Deactivated use can still log in
     assert form.validate() is True
     res = testapp.get('/user/%s' % user.username)
     assert 'under review' in res
Exemplo n.º 9
0
def login():
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user, remember=True)
            flash("You are logged in.", 'success')
            redirect_url = request.args.get("next") or url_for("public.home")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template("public/login.html", current_event=get_current_event(), form=form)
Exemplo n.º 10
0
def login():
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user, remember=True)
            flash("You are logged in.", 'success')
            redirect_url = request.args.get("next") or url_for("public.home")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template("public/login.html",
                           current_event=current_event(),
                           form=form,
                           slack_enabled=slack_enabled())
Exemplo n.º 11
0
def login():
    # Skip login form on forced SSO
    if request.method == "GET" and current_app.config["DRIBDAT_NOT_REGISTER"]:
        if not request.args.get('local') and oauth_type():
            return redirect(url_for(oauth_type() + '.login'))
    form = LoginForm(request.form)
    # Handle logging in
    if request.method == 'POST':
        if form.validate_on_submit():
            login_user(form.user, remember=True)
            flash("You are logged in.", 'success')
            redirect_url = request.args.get("next") or url_for("public.home")
            return redirect(redirect_url)
        else:
            flash_errors(form)
    return render_template("public/login.html",
                           current_event=current_event(),
                           form=form,
                           oauth_type=oauth_type())
Exemplo n.º 12
0
 def test_validate_unknown_username(self, db):
     """Unknown username."""
     form = LoginForm(username='******', password='******')
     assert form.validate() is False
     assert 'Unknown username' in form.username.errors
     assert form.user is None
Exemplo n.º 13
0
 def test_validate_unknown_username(self, db):
     """Unknown username."""
     form = LoginForm(username='******', password='******')
     assert form.validate() is False
     assert 'Unknown username' in form.username.errors
     assert form.user is None