def setUp(self): # clean DB db.users.drop() db.events.drop() db.groups.drop() # create normal user a = unicode(uuid.uuid1()) u = User.create(username=u'test', password=u'test', roles=[u'authenticated'], signup_email=u'test@localhost', activation_key=a, active=True) #print u self.assertNotEqual(u, None) # create a moderator a = unicode(uuid.uuid1()) u = User.create(username=u'mod', password=u'mod', roles=[u'authenticated', u'moderator'], signup_email=u'mod@localhost', activation_key=a, active=True) #print u self.assertNotEqual(u, None)
def adduser(user, password, email, moderator=False): # create normal user a = unicode(uuid.uuid1()) u = User.create(username=unicode(user), password=unicode(password), signup_email=unicode(email), activation_key=a, ) u.active = True if moderator: u.roles.append(u"moderator") u.save()
def adduser(user, password, email, moderator=False): # create normal user a = unicode(uuid.uuid1()) u = User.create( username=unicode(user), password=unicode(password), signup_email=unicode(email), activation_key=a, ) u.active = True if moderator: u.roles.append(u"moderator") u.save()
def login(): form = Login_Form(username=request.args.get("username", None), next=request.args.get("next", None)) if form.validate_on_submit(): user, authenticated = User.authenticate(form.username.data, form.password.data) if user and authenticated: login_user(user) flash("Logged in successfully.") return redirect( url_for('accounts.profile', username=user.username)) flash("Sorry, wrong credentials") return render_template('accounts/login.html', form=form)
def login(): form = Login_Form(username=request.args.get("username", None), next=request.args.get("next", None)) if form.validate_on_submit(): user, authenticated = User.authenticate(form.username.data, form.password.data) if user and authenticated: login_user(user) flash("Logged in successfully.") return redirect(url_for('accounts.profile', username=user.username)) flash("Sorry, wrong credentials") return render_template('accounts/login.html', form=form)
def test_create_user_and_login_without_activation(self): a = unicode(uuid.uuid1()) p = db.Profile() u = User.create(username=u'test99', password=u'test99', signup_email=u'test@localhost', activation_key=a, ) self.assertNotEqual(u, None) response = self.client.post("/users/login", data={'username': '******', 'password': '******'}) self.assert200(response) assert "Sorry, wrong credentials" in response.data
def create_user(self, username): u = User.create( username=username, password=u'hallo', signup_email=u'planlos-test1@localhost')
def create_user(self, username): u = User.create(username=username, password=u'hallo', signup_email=u'planlos-test1@localhost')
def profile(username): user = User.get_by_name(username) userprofile = user.profile return render_template('accounts/profile.html', user=user, profile=profile)