def make_user(self, username='******', password='******'): user = User.create( username = username, password_1 = password, password_2 = password, ) flush() return user
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)
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'))
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)
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'))
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
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)
def make_user(username="******", password="******"): user = User.create(username=username, password_1=password, password_2=password) flush() return user