def create_users(): for u in (('matt','*****@*****.**','password',['admin'],True), ('joe','*****@*****.**','password',['editor'],True), ('jill','*****@*****.**','password',['author'],True), ('tiya','*****@*****.**','password',[],False)): user_datastore.create_user(username=u[0], email=u[1], password=u[2], roles=u[3], active=u[4])
def create_users(): for u in (('matt', '*****@*****.**', 'password', ['admin'], True), ('joe', '*****@*****.**', 'password', ['editor'], True), ('jill', '*****@*****.**', 'password', ['author'], True), ('tiya', '*****@*****.**', 'password', [], False)): user_datastore.create_user(username=u[0], email=u[1], password=u[2], roles=u[3], active=u[4])
def run(self, **kwargs): # sanitize active input ai = re.sub(r'\s', '', str(kwargs['active'])) kwargs['active'] = ai.lower() in ['', 'y','yes', '1', 'active'] # sanitize role input a bit ri = re.sub(r'\s', '', kwargs['roles']) kwargs['roles'] = [] if ri == '' else ri.split(',') user_datastore.create_user(**kwargs) print 'User created successfully.' kwargs['password'] = '******' pprint(kwargs)
def run(self, **kwargs): # sanitize active input ai = re.sub(r'\s', '', str(kwargs['active'])) kwargs['active'] = ai.lower() in ['', 'y', 'yes', '1', 'active'] # sanitize role input a bit ri = re.sub(r'\s', '', kwargs['roles']) kwargs['roles'] = [] if ri == '' else ri.split(',') user_datastore.create_user(**kwargs) print 'User created successfully.' kwargs['password'] = '******' pprint(kwargs)
def admin(): if request.method == 'POST': new_user = request.form['user'] new_email = request.form['email'] new_pass = request.form['pass'] new_role = request.form['role'] if new_role == 'admin': user_datastore.create_user(username=new_user, email=new_email, password=new_pass, roles=['admin']) else: user_datastore.create_user(username=new_user, email=new_email, password=new_pass, roles=['user']) flash('Thanks for registering') return redirect(url_for('admin')) subjects = Subject.query.order_by(Subject.name) choices = Choice.query.order_by(Choice.choice.desc()) output = render_template('admin.html', subjects=subjects, choices=choices) return output
def register(): form=RegistrationForm() if form.validate_on_submit(): user = user_datastore.create_user(username=form.username.data, email=form.email.data, password=form.password.data, roles=[], active=False) activation_key = RegistrationKey(user_id = user.get_id()) db.session.add(activation_key) db.session.commit() encoded_id = encode_id(activation_key.id) activate_url = app.config.get('SITE_ROOT_URL') + url_for('security.activate', activationid = encoded_id) mail.send_message(recipients=[form.email.data], html=render_template('email/registration.html', activate_url = activate_url, user=user), subject="Registration information for %s" % app.config.get('SITE_NAME')) flash("Please check your email, %s for activation instructions" % form.email.data) return redirect(url_for('security.profile')) return render_template('security/login.html', content='Registration', form=form, action=url_for('security.register'))
def create_users(): for u in (('matt','*****@*****.**','password'),): user_datastore.create_user( username=u[0], email=u[1], password=u[2])
def before_first_request(): user_datastore.create_role(name='admin') user_datastore.create_user(username='******', email='*****@*****.**', password='******', roles=['admin'])
def create_users(): for u in (('matt', '*****@*****.**', 'password'), ): user_datastore.create_user(username=u[0], email=u[1], password=u[2])