예제 #1
0
 def make_user(self, username='******', password='******'):
     user = User.create(
         username = username,
         password_1 = password,
         password_2 = password,
     )
     flush()
     return user
예제 #2
0
 def handle_request(*args, **kwargs):
     if APP_KEY_URL_PARAM in request.args:
         user = User.from_app_key_hex(request.args[APP_KEY_URL_PARAM])
         if user:
             kwargs['api_user'] = user
             return fun(*args, **kwargs)
         else:
             # CRITICAL: Don't let people explore the app_key space!
             return abort(404)
     else:
         return abort(403)
예제 #3
0
def perform_login():
    try:
        user = User.for_login(username=request.form['username'],
                              password=request.form['password'])
        login_user(user)

        flash('Logged in', category='success')
        return redirect(default_page())
    except AuthenticationError as error:
        flash(str(error), category='danger')
        return redirect(url_for('users.login_form'))
예제 #4
0
    def test_logging_out_works_with_user(self, client):
        user = User.create(
            username = '******',
            password_1 = '9898dhfaksh723SS@',
            password_2 = '9898dhfaksh723SS@'
        )
        flush()

        response = client.get('/users/perform_logout', follow_redirects=True)

        assert(b"Logged out" in response.data)
예제 #5
0
def create_user():
    try:
        user = User.create(username=request.form['name'],
                           password_1=request.form['password_1'],
                           password_2=request.form['password_2'])
        login_user(user)

        flash("Your account was created", category='success')
        return redirect(default_page())
    except (AuthenticationError, ValueError) as error:
        flash(str(error), category='danger')
        return redirect(url_for('users.new_user'))
예제 #6
0
    def test_can_find_user_by_id_for_login_manager(self, client):
        user = User.create(
            username = '******',
            password_1 = 'mittens1982',
            password_2 = 'mittens1982'
        )
        flush()

        assert int(user.get_id()) == user.get_pk()

        lookup = User[user.get_id()]
        assert lookup == user
예제 #7
0
    def test_fails_with_duplicate_user(self, client):
        user = User.create(
            username = '******',
            password_1 = 'somepass',
            password_2 = 'somepass',
        )

        flush()

        response = client.post('/users/create', follow_redirects=True, data=dict(
            name = "my_organization",
            password_1 = "mypass",
            password_2 = "mypass"
        ))

        assert(b"This username is taken" in response.data)

        users = count(u for u in User if u.name == "my_organization")

        assert(users == 1)
예제 #8
0
def make_user(username="******", password="******"):
    user = User.create(username=username,
                       password_1=password,
                       password_2=password)
    flush()
    return user