def create_users(): for u in (('acbart','Austin Cory Bart', '*****@*****.**','password',['admin'],True), ('rcastle','Rick Castle', '*****@*****.**','password',['teacher'],True), ('lelouch','Lelouch Lamperouge', '*****@*****.**','password',['student'],True), ('kirk','James Kirk', '*****@*****.**','password',['developer'],True)): user_datastore.create_user(username=u[0], name=u[1], email=u[2], password=u[3], roles=u[4], active=u[5]) db.session.commit()
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]) user_datastore.commit()
def create_users(): for u in (('matt', '*****@*****.**', 'password', ['admin'], True), ('jill', '*****@*****.**', 'password', ['author'], True), ('tiya', '*****@*****.**', 'password', [], False)): user_datastore.create_user(email=u[1], password=encrypt_password(u[2]), roles=u[3], active=u[4], confirmed_at=datetime.datetime.now() ) user_datastore.commit()
def create_users(): for u in (('matt', '*****@*****.**', 'password', ['admin'], True), ('jill', '*****@*****.**', 'password', ['author'], True), ('tiya', '*****@*****.**', 'password', [], False)): user_datastore.create_user(email=u[1], password=encrypt_password(u[2]), roles=u[3], active=u[4], confirmed_at=datetime.datetime.now()) user_datastore.commit()
def invite(): """ Invite a new person """ form = InviteForm(request.form) if form.validate_on_submit(): from flask_application import user_datastore, app, mail user = User.objects(id=current_user.get_id()).first() password = binascii.b2a_hex(os.urandom(15)) # create an account user_datastore.create_user(username="******", email=form.email.data, password=encrypt_password(password), roles=['contributor'], active=True, invited_by=user) user_datastore.commit() invitee = User.objects(email=form.email.data).first() # set inviter data user.add_invitation(invitee) # send an email msg = Message("An invitation to %s" % app.config['SITE_NAME'], sender=app.config['DEFAULT_MAIL_SENDER'], recipients=[form.email.data]) msg.body = ''' You have been invited to %s by %s. Your can log in with the following username/ password: %s %s You can change this random, complicated password after you have logged in. ''' % (app.config['SITE_NAME'], user.email, form.email.data, password) mail.send(msg) # @todo: set invited and invited by flash( "An account has been created for %s and an email has been sent. You may want to let them know that it is coming." % form.email.data) return render_template('profiles/invite.html', register_user_form=form)
def invite(): """ Invite a new person """ form = InviteForm(request.form) if form.validate_on_submit(): from flask_application import user_datastore, app, mail user = User.objects(id=current_user.get_id()).first() password = binascii.b2a_hex(os.urandom(15)) # create an account user_datastore.create_user(username="******", email=form.email.data, password=encrypt_password(password), roles=['contributor'], active=True, invited_by=user) user_datastore.commit() invitee = User.objects(email=form.email.data).first() # set inviter data user.add_invitation(invitee) # send an email msg = Message("An invitation to %s" % app.config['SITE_NAME'], sender=app.config['DEFAULT_MAIL_SENDER'], recipients=[form.email.data]) msg.body = ''' You have been invited to %s by %s. Your can log in with the following username/ password: %s %s You can change this random, complicated password after you have logged in. ''' % (app.config['SITE_NAME'], user.email, form.email.data, password) mail.send(msg) # @todo: set invited and invited by flash("An account has been created for %s and an email has been sent. You may want to let them know that it is coming." % form.email.data) return render_template('profiles/invite.html', register_user_form=form)
def create_users(): db.create_all() user_datastore.create_user(email='*****@*****.**', password='******') db.session.commit()