Esempio n. 1
0
def register(registration_id):
    new_user = user.get_by_registration_id(registration_id)
    if not new_user or new_user.is_registered:
        return redirect(url_for('views.home'), code=302)

    if request.method == 'POST':
        registration_form = request.form
        new_password = registration_form.get('password', '')
        if len(new_password) < 6:
            return render_template('register.html', attempt={'failure':True}, user=new_user)

        user.register(registration_id, new_password)
        return redirect(url_for('views.home'), code=302)

    return render_template('register.html', attempt={}, user=new_user)
Esempio n. 2
0
def register(registration_id):
    new_user = user.get_by_registration_id(registration_id)
    if not new_user or new_user.is_registered:
        return redirect(url_for('views.home'), code=302)

    if request.method == 'POST':
        registration_form = request.form
        new_password = registration_form.get('password', '')
        if len(new_password) < 6:
            return render_template('register.html', attempt={'failure':True}, user=new_user)

        user.register(registration_id, new_password)
        return redirect(url_for('views.home'), code=302)

    return render_template('register.html', attempt={}, user=new_user)
Esempio n. 3
0
def register(registration_id):
    new_user = user.get_by_registration_id(registration_id)
    if not new_user or new_user.is_registered:
        return redirect(url_for("views.home"), code=302)

    if request.method == "POST":
        registration_form = request.form
        new_password = registration_form.get("password", "")
        if len(new_password) < 6:
            return render_template("register.html", attempt={"failure": True}, user=new_user)

        user.register(registration_id, new_password)
        return redirect(url_for("views.home"), code=302)

    return render_template("register.html", attempt={}, user=new_user)
Esempio n. 4
0
    def test_success(self, logout_user_mock, login_user_mock):
        new_user = user.create_user('*****@*****.**', 'admin')

        new_user = user.register(new_user.registration_id, '1234password')
        password, user_hash = user.hash_password('1234password', new_user.hash_code)

        self.assertEqual(password, new_user.password)

        self.assertEqual(new_user.is_registered, True)
Esempio n. 5
0
 def test_user_exists(self):
     user.User(registration_id='1234', is_registered=True).put()
     self.assertEqual(user.register('1234', 'fake password'), None)
Esempio n. 6
0
    def test_user_dne(self, logout_user_mock, login_user_mock):
        new_user = user.create_user('*****@*****.**', 'admin')
        new_user = user.register(new_user.registration_id, '1234password')

        self.assertFalse(user.login('*****@*****.**', '1234password'))
Esempio n. 7
0
    def test_password_incorrect(self, logout_user_mock, login_user_mock):
        new_user = user.create_user('*****@*****.**', 'admin')
        new_user = user.register(new_user.registration_id, 'aaaaaa')

        self.assertFalse(user.login('*****@*****.**', 'wrong password'))
Esempio n. 8
0
    def test_success(self, logout_user_mock, login_user_mock):
        new_user = user.create_user('*****@*****.**', 'admin')
        new_user = user.register(new_user.registration_id, '1234password')

        self.assertTrue(user.login('*****@*****.**', '1234password'))