示例#1
0
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])
示例#2
0
文件: app.py 项目: kcm/flask-security
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])
示例#3
0
 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)
示例#4
0
    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)
示例#5
0
文件: augur.py 项目: szweibel/Augur
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
示例#6
0
文件: augur.py 项目: szweibel/Augur
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
示例#7
0
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'))
示例#8
0
def create_users():
    for u in  (('matt','*****@*****.**','password'),):
        user_datastore.create_user(
            username=u[0], email=u[1], password=u[2])
示例#9
0
文件: app.py 项目: rosantiago/meyahil
def before_first_request():
    user_datastore.create_role(name='admin')
    user_datastore.create_user(username='******', email='*****@*****.**',
                               password='******', roles=['admin'])
示例#10
0
def create_users():
    for u in (('matt', '*****@*****.**', 'password'), ):
        user_datastore.create_user(username=u[0], email=u[1], password=u[2])