def register_local(): form = Art17LocalRegisterForm(request.form) if form.validate_on_submit(): register_user(**form.to_dict()) return render_template('message.html', message="") return render_template('auth/register_local.html', **{ 'register_user_form': form, })
def register(): ''' Vendor registration page if GET - render the registration page if POST - validate the form and redirect to the customer setup pages ''' form = VendorRegisterForm() # if POST if request.method == 'POST' and form.validate_on_submit(): registration_data = form.to_dict() data = form.data # create address model out of form address = Address() form.populate_obj(address) # create user model out of form, and add address user = register_user(**registration_data) user.address = address user.update_subscribe(data.get('subscribe')) # create vendor model out of user vendor = Vendor(user=user, company_name=data.get('company_name')) form.populate_obj(vendor) # commmit! db.session.add(vendor) db.session.commit() return redirect('/') # if GET return render_template('account/vendor/register.html', form=form)
def register_user(self): schema = RELS['v1.AuthView:register'][request.method] try: data = request_register_options.parse_args() validate(data, schema, format_checker=FormatChecker()) invite_token = data['token'] if invite_token: expired, invalid, invitor = get_token_status(invite_token, 'invite', 'USE_INVITE') if invalid or not invitor: return dict(status=409, message="Invite is invalid"), 409 if expired: return dict(status=409, message="Invite has expired"), 409 inviteTokenObj = Invite.find(token=invite_token).first() if not inviteTokenObj: return dict(status=409, message="Invite not found"), 409 if inviteTokenObj.invitee_id: return dict(status=409, message="Invite already used"), 409 password = encrypt_password(data['password']) user = register_user(email=data['email'], password=password, first_name=data['firstName'], last_name=data['lastName'], roles=[Role.first(name='user')]) if invite_token: inviteTokenObj.invitee_id = user.id inviteTokenObj.save() token = generate_confirmation_token(user) confirmation_link = urljoin(current_app.config['CLIENT_DOMAIN'], '/#/confirm?token='+token) #TODO this mail send should be performed asynchronously using celery, see issue #88850472 send_message( subject='Please Confirm Your FogMine Account', sender="*****@*****.**", recipients = [user.email], html_body=render_template('email/activate.html', user=user, confirmation_link=confirmation_link), text_body=render_template('email/activate.txt', user=user, confirmation_link=confirmation_link) ) user_data = generate_response_dict(user=user) #SEE 90454516, Login the user login_user(user) user.save() #saving the user as a precaution, want the log data return dict(status=201, message='A confirmation email has been sent to '+user.email, user=user_data), 201 except ValidationError as e: return dict(status=400, message=e.message), 400 except IntegrityError: return {'status': 409, 'message': 'An account with that email already exists.'}, 409 except werkzeug.exceptions.ClientDisconnected: return dict(status=400, message='one or more required arguments missing from this request'), 400
def run(self): email = prompt('Email') password = prompt_pass('Password') password_confirm = prompt_pass('Confirm Password') fullname = prompt('Fullname') tel = prompt('Tel') active = bool(prompt('Actvice immediately', default='True')) role = prompt('Role', default='admin') data = MultiDict( dict(email=email, password=password, password_confirm=password_confirm, fullname=fullname, tel=tel, active=active, role=role)) form = RegisterForm(data, csrf_enabled=False) if form.validate(): user = register_user(email=email, password=password, fullname=fullname, tel=tel, active=active, role=role) print("\nUser created successfully") print("User(id=%s,email=%s,fullname=%s)" % (user.id, user.email, user.fullname)) return print("\nError creating user:"******"\n".join(errors))
def login(): current_app.logger.info( 'Try to authenticate a user with mails: %s' % request.environ.get( current_app.config.get('WEBAUTHCLIENT_REMOTE_MAIL'))) mails = request.environ.get( current_app.config.get('WEBAUTHCLIENT_REMOTE_MAIL')).replace( ';', ',').split(',') for mail in mails: user = User.query.filter_by(email=mail).one_or_none() if user is not None: break if user is None: password = ''.join( choice(ascii_uppercase + ascii_lowercase + digits) for _ in range(16)) user = register_user(password=password, email=mails[0], active=True, confirmed_at=datetime.now()) login_user(user, remember=False) return redirect(request.args.get('next'))
def run(self): email = prompt('Email') password = prompt_pass('Password') password_confirm = prompt_pass('Confirm Password') ListRolesCommand().run() role_names = prompt("This user's comma-separated roles") role_models = [] for name in role_names.split(','): r = roles.first(name=name.strip()) if not r: print('Invalid role: %s' % name.strip()) else: role_models.append(r) data = MultiDict(dict(email=email, password=password, password_confirm=password_confirm)) form = RegisterForm(data, csrf_enabled=False) if form.validate(): user = register_user(email=email, password=password) user.roles = role_models db.session.add(user) db.session.commit() print('\nUser created successfully') print('User(id=%s email=%s, roles=%s)' % (user.id, user.email, ','.join([r.name for r in user.roles]))) else: print('\nError creating user:'******'\n'.join(errors))
def register_user(self): """Prompt for user details.""" # Get the information. email = prompt('Email') name = prompt('Name') password = prompt_pass('Password') password_confirm = prompt_pass('Confirm Password') data = MultiDict({ 'email': email, 'password': password, 'password_confirm': password_confirm, }) # Validate the form. form = RegisterForm(data, csrf_enabled=False) if form.validate(): # Register the new user. user = register_user(name=name, email=email, password=password) print('\nUser created successfully.') print('User(id={} email={})'.format(user.id, user.email)) return user # If something went wrong, report it and exit out. print('\nError creating user:'******'\n'.join(errors)) sys.exit(1)
def user2(db_session): user = register_user(username='******', email='*****@*****.**', password='******') db_session.add(user) db_session.commit() return user
def callback(): # Get authorization code Google sent back to you code = request.args.get("code") current_app.logger.debug('CODE IS: %s' %code) # Find out what URL to hit to get tokens that allow you to ask for # things on behalf of a user google_provider_cfg = get_google_provider_cfg() token_endpoint = google_provider_cfg["token_endpoint"] # Prepare and send a request to get tokens! Yay tokens! token_url, headers, body = client.prepare_token_request( token_endpoint, authorization_response=request.url, redirect_url=request.base_url, code=code ) token_response = requests.post( token_url, headers=headers, data=body, auth=(_clientId, _clientSecret) ) # Parse the tokens! client.parse_request_body_response(json.dumps(token_response.json())) # Now that you have tokens (yay) let's find and hit the URL # from Google that gives you the user's profile information, # including their Google profile image and email userinfo_endpoint = google_provider_cfg["userinfo_endpoint"] current_app.logger.debug('USR_NFO_EPT: %s' %userinfo_endpoint) uri, headers, body = client.add_token(userinfo_endpoint) userinfo_response = requests.get(uri, headers=headers, data=body) # You want to make sure their email is verified. # The user authenticated with Google, authorized your # app, and now you've verified their email through Google! if userinfo_response.json().get("email_verified"): unique_id = userinfo_response.json()["sub"] users_email = userinfo_response.json()["email"] picture = userinfo_response.json()["picture"] users_name = userinfo_response.json()["given_name"] if users_email is not None: user = User.query.filter(func.lower(User.email) == func.lower(users_email)).one_or_none() if user is None: password = ''.join(choice(ascii_uppercase + ascii_lowercase + digits) for _ in range(16)) user = register_user(password=password, email=users_email.lower(), active=True, confirmed_at=datetime.now()) login_user(user, remember=False) else: return "User email not available or not verified by Google.", 400 return redirect('/')
def create_view(self): template = self.create_template form = OyRegisterForm() if form.validate(): if not current_app.debug: register_user(**form.to_dict()) else: user_data = form.to_dict() user_datastore.create_user( user_name=user_data["user_name"], email=user_data["email"], password=hash_password(user_data["password"]), roles=user_data["roles"], ) db.session.commit() flash(gettext("User created successfully.")) return redirect(url_for(".index_view")) return self.render(template, form=form)
def oauth_register(form): """Register user if possible.""" if form.validate(): data = form.to_dict() if not data.get('password'): data['password'] = '' user = register_user(**data) if not data['password']: user.password = None _datastore.commit() return user
def oauth_register(account_info, form_data=None): """Register user if possible.""" email = account_info.get("email") if form_data and form_data.get("email"): email = form_data.get("email") if email: form_data['password'] = None user = register_user(**form_data) return user return None
def create_superuser(email, password): admin = user_datastore.find_or_create_role('admin') user = User.query.filter_by(email=email).first() if not user: user = register_user(email=email, password=password) user.confirmed_at = datetime.now() db.session.add(user) db.session.commit() user_datastore.add_role_to_user(user, admin) db.session.commit()
def createuser(email=None): "Add a new user to the database" if not email: email = prompt("Please enter the email of the new user") while (not is_email_valid(email)): email = prompt("Please enter the email of the new user") password = prompt_pass("Please enter the password") password2 = prompt_pass("Please enter the password again") while (password != password2): print("Passwords are different, please enter the 2Â passwords again.", file=sys.stderr) password = prompt_pass("Please enter the password") password2 = prompt_pass("Please enter the password again") #credit = prompt("Please enter the credit (number of hours), -1 for no limit") credit = -1 french_model = AsrModel.query.filter_by(name='french.studio.fr_FR').first() english_model = AsrModel.query.filter_by(name='english.studio').first() models = [] if french_model: models.append(french_model) if english_model: models.append(english_model) registerable.register_user(email=email, password=password, credit=credit, asr_models=models) db.session.commit() print("User '{user}' created successfully!".format(user=email))
def create_user(self, **kwargs): """ Create a new user. (Registration) :param kwargs: :return: """ kwargs = DictEncoder.encode(kwargs) kwargs['email'] = kwargs.pop('registrationEmail') kwargs['password'] = kwargs.pop('registrationPassword') # for k in kwargs: # print(k) user = register_user(**kwargs) db.session.commit() return user
def run(self): email = prompt('Email') password = prompt_pass('Password') password_confirm = prompt_pass('Confirm Password') data = MultiDict(dict(email=email, password=password, password_confirm=password_confirm)) form = RegisterForm(data, csrf_enabled=False) if form.validate(): user = register_user(email=email, password=password) print('\nUser created successfully') print('User(id=%s email=%s)' % (user.id, user.email)) return print('\nError creating user:'******'\n'.join(errors))
def run(self): email = prompt('Email') password = prompt_pass('Password') password_confirm = prompt_pass('Confirm Password') data = MultiDict(dict(email=email, password=password, password_confirm=password_confirm)) form = RegisterForm(data, csrf_enabled=False) if form.validate(): user = register_user(email=email, password=password) print '\nUser created successfully' print 'User(id=%s email=%s)' % (user.id, user.email) return print '\nError creating user:'******'\n'.join(errors)
def oauth_register(form): """Register user if possible. :param form: A form instance. :returns: A :class:`invenio_accounts.models.User` instance. """ if form.validate(): data = form.to_dict() if not data.get('password'): data['password'] = '' user = register_user(**data) if not data['password']: user.password = None _datastore.commit() return user
def register(): form = RegisterForm(MultiDict(request.json)) if request.method == 'POST': if form.validate_on_submit(): user = register_user(**form.to_dict()) form.user = user login_user(user) return jsonify({ 'success': { 'user': form.user.get_security_payload(), 'token': form.user.get_auth_token() } }), 200 return jsonify({'errors': form.errors}), 400 return render_template("register.html", register_user_form=form)
def run(self): email = prompt("Email") password = prompt_pass("Password") password_confirm = prompt_pass("Confirm password") data = MultiDict(dict(email=email, password=password, password_confirm=password_confirm)) form = RegisterForm(data, csrf_enabled=False) if form.validate(): user = register_user(email=email, password=password) print "\nUser created." print "<User id=%s email=%s>" % (user.id, user.email) else: print "Error:" for errors in form.errors.values(): print "\n".join(errors)
def oauth_register(account_info): """Register new OAuth users. This is needed as we don't use Flask Forms (for now), thus the default function would fail. """ from flask_security.registerable import register_user user_data = account_info.get("user") user_data['password'] = '' user = register_user(**user_data) # Create user <-> external id link. oauth_link_external_id( user, dict(id=str(account_info.get('external_id')), method=account_info.get('external_method'))) return user
def run(self): email = prompt("Email") password = prompt_pass("Password") password_confirm = prompt_pass("Confirm password") data = MultiDict( dict(email=email, password=password, password_confirm=password_confirm)) form = RegisterForm(data, csrf_enabled=False) if form.validate(): user = register_user(email=email, password=password) print "\nUser created." print "<User id=%s email=%s>" % (user.id, user.email) else: print "Error:" for errors in form.errors.values(): print "\n".join(errors)
def register(): if _security.confirmable or request.is_json: form_class = _security.confirm_register_form else: form_class = _security.register_form if request.is_json: form_data = MultiDict(request.get_json()) else: form_data = request.form form = form_class(form_data) if form.validate_on_submit(): user_data = {'email': form.email.data, 'password': form.password.data} user = register_user(**user_data) contact = Contact(first_name=form.contact.first_name.data, last_name=form.contact.last_name.data, email=form.email.data, phone=form.contact.phone.data) company = Company(name=form.company.company_name.data) role = Role.query.filter_by(name="Company Admin").first_or_404() user.add_role(role) user.company = company user.contact = contact form.user = user if not _security.confirmable or _security.login_without_confirmation: after_this_request(_commit) login_user(user) if not request.is_json: if 'next' in form: redirect_url = get_post_register_redirect(form.next.data) else: redirect_url = get_post_register_redirect() return redirect(redirect_url) return _render_json(form, include_auth_token=True) if request.is_json: return _render_json(form) return _security.render_template('/security/register_user.html', register_user_form=form, **_ctx('register'))
def register(self): title = REGISTER_TITLE return_url = get_redirect_target or self.get_url('admin.index') form = self.register_form() self._remove_fields_from_form_instance(['submit'], form) if self.validate_form(form): user = register_user(**form.to_dict()) form.user = user template = self.register_template return self.render(template, form=form, title=title, return_url=return_url)
def create(first_name=None, last_name=None, email=None, password=None): first_name = first_name or prompt('First Name'), last_name = last_name or prompt('Last Name'), email = email or prompt('Email'), password = password or prompt_pass('Password') form = RegisterForm(MultiDict(dict(first_name=first_name, last_name=last_name, email=email, password=password, password_confirm=prompt_pass('Confirm Password'), accept_tos=True)), csrf_enabled=False) if form.validate(): user = register_user(first_name=first_name, last_name=last_name, email=email, password=password) print('%s created successfully' % repr(user)) return print('Error creating user:'******'\n'.join(errors))
def oauth_register(account_info): """Register new OAuth users. This is needed as we don't use Flask Forms (for now), thus the default function would fail. """ from flask_security.registerable import register_user user_data = account_info.get("user") user_data['password'] = '' user = register_user(**user_data) # Create user <-> external id link. oauth_link_external_id( user, dict( id=str(account_info.get('external_id')), method=account_info.get('external_method') ) ) return user
def register(): error = _validate_register_request_json(request.get_json()) if error != None: return error email = request.get_json()['email'] password = request.get_json()['password'] username = request.get_json()['username'] roles = [Role.query.filter_by(name='contestant').first()] solves = [ Solve(solved=False, challenge=challenge) for challenge in Challenge.query.all() ] new_user = register_user(email=email, password=password, username=username, roles=roles, solves=solves) login_user(new_user) return (jsonify({'authentication_token': new_user.get_auth_token()}), 200)
def create(first_name=None, last_name=None, email=None, password=None): first_name = first_name or prompt('First Name'), last_name = last_name or prompt('Last Name'), email = email or prompt('Email'), password = password or prompt_pass('Password') form = RegisterForm(MultiDict( dict(first_name=first_name, last_name=last_name, email=email, password=password, password_confirm=prompt_pass('Confirm Password'), accept_tos=True)), csrf_enabled=False) if form.validate(): user = register_user(first_name=first_name, last_name=last_name, email=email, password=password) print('%s created successfully' % repr(user)) return print('Error creating user:'******'\n'.join(errors))
def register(): ''' Customer registration page if GET - render the registration page if POST - validate the form and redirect to the customer setup pages ''' form = GradientConfirmRegisterForm() # if POST if form.validate_on_submit(): data = form.to_dict() user = register_user(**data) customer = Customer(user=user) form.populate_obj(customer) db.session.add(customer) db.session.commit() login_user(user) return redirect(url_for('customer.onboarding')) # if GET return render_template('account/customer/register.html', register_user_form=form)
def setUp(self): # Register a user and login. # NOTE: merely "creating" a user (i.e. not "registering") does NOT hash the password which is problemating when comparing submitted (and hashed) passwords. register_user(**self.userdata) self.client.post("/test_login", data={"id": 1})
def seed(debug=False): # Patch out saving images to S3. patcher = patch('argos.util.storage.save_from_url', autospec=True, return_value='https://i.imgur.com/Zf9mXlj.jpg') patcher.start() seeds = open('manage/core/data/seed.json', 'r') sample_images = [ 'https://upload.wikimedia.org/wikipedia/commons/d/d5/Michael_Rogers_-_Herbiers_2004.jpg', 'https://upload.wikimedia.org/wikipedia/commons/6/6e/Brandenburger_Tor_2004.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/ad/ChicagoAntiGaddafiHopeless.jpg/576px-ChicagoAntiGaddafiHopeless.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/Evo_morales_2_year_bolivia_Joel_Alvarez.jpg/640px-Evo_morales_2_year_bolivia_Joel_Alvarez.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/9f/2010_wet_season_cloud_over_colombia.jpg/640px-2010_wet_season_cloud_over_colombia.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Barack_Obama_at_Las_Vegas_Presidential_Forum.jpg/640px-Barack_Obama_at_Las_Vegas_Presidential_Forum.jpg' 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/2010-10-23-Demo-Stuttgart21-Befuerworter.png/640px-2010-10-23-Demo-Stuttgart21-Befuerworter.png', 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/fc/51%C2%BA_Congresso_da_UNE_%28Conune%29.jpg/640px-51%C2%BA_Congresso_da_UNE_%28Conune%29.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Tough_return%2C_365.35.jpg/640px-Tough_return%2C_365.35.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Saint_Isaac%27s_Cathedral_in_SPB.jpeg/800px-Saint_Isaac%27s_Cathedral_in_SPB.jpeg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Ponta_de_S%C3%A3o_Louren%C3%A7o_north_north_east.jpg/800px-Ponta_de_S%C3%A3o_Louren%C3%A7o_north_north_east.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/TU_Bibl_01_DSC1099w.jpg/644px-TU_Bibl_01_DSC1099w.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/fe/%D0%9C%D0%B0%D0%BA%D0%B5%D0%B4%D0%BE%D0%BD%D0%B8%D1%83%D0%BC_-_%D0%9A%D1%80%D1%83%D1%88%D0%B5%D0%B2%D0%BE.jpg/800px-%D0%9C%D0%B0%D0%BA%D0%B5%D0%B4%D0%BE%D0%BD%D0%B8%D1%83%D0%BC_-_%D0%9A%D1%80%D1%83%D1%88%D0%B5%D0%B2%D0%BE.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/64/Puente_Mong%2C_Ciudad_Ho_Chi_Minh%2C_Vietnam%2C_2013-08-14%2C_DD_01.JPG/800px-Puente_Mong%2C_Ciudad_Ho_Chi_Minh%2C_Vietnam%2C_2013-08-14%2C_DD_01.JPG', 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Autignac%2C_H%C3%A9rault_01.jpg/800px-Autignac%2C_H%C3%A9rault_01.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/Caesio_teres_in_Fiji_by_Nick_Hobgood.jpg/800px-Caesio_teres_in_Fiji_by_Nick_Hobgood.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Ash_in_Yogyakarta_during_the_2014_eruption_of_Kelud_01.jpg/800px-Ash_in_Yogyakarta_during_the_2014_eruption_of_Kelud_01.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/b/bd/12-07-12-wikimania-wdc-by-RalfR-010.jpg/800px-12-07-12-wikimania-wdc-by-RalfR-010.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/Mortagne-sur-Gironde_Civellier_Mayflowers_2013.jpg/800px-Mortagne-sur-Gironde_Civellier_Mayflowers_2013.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/British_Museum_Great_Court%2C_London%2C_UK_-_Diliff.jpg/611px-British_Museum_Great_Court%2C_London%2C_UK_-_Diliff.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/26/Mercedes-Benz_Museum_201312_08_blue_hour.jpg/800px-Mercedes-Benz_Museum_201312_08_blue_hour.jpg' ] print('Resetting the database...') db.reflect() db.drop_all() db.create_all() # Create sources print('Creating sources...') create_sources() num_sources = Source.query.count() print('Created {0} sources.'.format(num_sources)) # Create articles entries = json.load(seeds) print('Seeding {0} articles...'.format(len(entries))) articles = [] for entry in entries: if debug: print(json.dumps(entry, sort_keys=True, indent=4)) feed = Feed.query.filter_by(ext_url=entry['source']).first() a = Article( ext_url=entry['url'], feed=feed, source=feed.source, html=entry['html'], text=entry['text'], tags=entry['tags'], title=entry['title'], created_at = parse(entry['published']), updated_at = parse(entry['updated']), image=random.choice(sample_images), # fake image score=random.random() * 100 # fake score ) articles.append(a) db.session.add(a) progress_bar(len(articles) / len(entries) * 100) print('Creating additional articles...') # Collect all appropriate files. all_files = [] for dir, subdir, files in os.walk('manage/core/data/organized_articles'): for file in files: filepath = os.path.join(dir, file) name, ext = os.path.splitext(filepath) if ext == '.txt': all_files.append((dir, name, filepath)) # Create articles for appropriate files. for dir, name, filepath in all_files: category = dir.split('/')[-1] f = open(filepath, 'r') article = Article( text=f.read(), title=name.split('/')[-1], ext_url='http://fauxurl/', source = Source.query.get(1), # fake source image=random.choice(sample_images), # fake image score=random.random() * 100 # fake score ) db.session.add(article) articles.append(article) progress_bar(len(articles)/len(all_files) * 100) db.session.commit() num_articles = Article.query.count() num_concepts = Concept.query.count() print('Seeded {0} articles.'.format(num_articles)) print('Found {0} concepts.'.format(num_concepts)) print('Clustering articles into events...') cluster.cluster(articles) num_events = Event.query.count() print('Created {0} event clusters.'.format(num_events)) print('Clustering events into stories...') # TO DO num_stories = Story.query.count() print('Created {0} story clusters.'.format(num_stories)) patcher.stop() print('\n\n==============================================') print('From {0} sources, seeded {1} articles, found {2} concepts, created {3} events and {4} stories.'.format(num_sources, num_articles, num_concepts, num_events, num_stories)) print('==============================================\n\n') client = current_app.test_client() ctx = current_app.test_request_context() ctx.push() register_user(email='[email protected]', password='******') ctx.pop() print('\n\n==============================================') print('Created a test user, email is [email protected], password is password') print('==============================================\n\n') client = Client( #client_id=gen_salt(40), #client_secret=gen_salt(50), client_id='test', client_secret='test', _redirect_uris='http://localhost:5000/authorized', _default_scopes='userinfo', _allowed_grant_types='authorization_code refresh_token password', user_id=None, is_confidential=True # make a confidential client. ) db.session.add(client) db.session.commit() print('\n\n==============================================') print('Created a test client:\nclient id: {0}\nclient secret: {1}'.format(client.client_id, client.client_secret)) print('==============================================\n\n')
def load_all_fixtures(db, app): user_datastore = SQLAlchemyUserDatastore(db, User, Role) # Load default fixtures role = user_datastore.create_role(name=app.config['VOXO_ROLE_USER'], description='User role') admin_role = user_datastore.create_role(name=app.config['VOXO_ROLE_ADMIN'], description='Admin role') server_role = user_datastore.create_role( name=app.config['VOXO_ROLE_SERVER'], description='Server role') user_vjousse = registerable.register_user(email='*****@*****.**', password='******') user_datastore.add_role_to_user(user_vjousse, role) print("{user} with token {token} created.".format( user=user_vjousse.email, token=user_vjousse.get_auth_token())) user = registerable.register_user(email='*****@*****.**', password='******') user_datastore.add_role_to_user(user, admin_role) user_datastore.add_role_to_user(user, role) print("{user} with token {token} created.".format( user=user.email, token=user.get_auth_token())) server = registerable.register_user(email='*****@*****.**', password='******') user_datastore.add_role_to_user(server, server_role) print("{user} with token {token} created.".format( user=server.email, token=server.get_auth_token())) asr_model_french = AsrModel(name="french.studio.fr_FR", description="General purpose french model") asr_model_french.users.append(user_vjousse) db.session.add(asr_model_french) db.session.flush() asr_model_english = AsrModel(name="english.studio", description="General purpose english model") asr_model_english.users.append(user_vjousse) db.session.add(asr_model_english) db.session.flush() media_file = MediaFile(filename='fixture_file.wav', status=FileStatus.Success, user_id=user_vjousse.id, size=2500, generated_filename='fixture_file_UUID.wav', duration=70) db.session.add(media_file) db.session.flush() process = Process( file_id=media_file.id, status=DecodeStatus.Queued, ) db.session.add(process) db.session.flush() transcription = Transcription( auto_filename='transcription.xml', ref_filename='transcription.txt', user_id=user_vjousse.id, ) db.session.add(transcription) db.session.flush() process = Process(file_id=media_file.id, status=DecodeStatus.Queued, type=ProcessType.TranscriptionAlignment, transcription_id=transcription.id) db.session.add(process) db.session.flush() db.session.commit()
def setUp(self): # Register a user and login. # NOTE: merely "creating" a user (i.e. not "registering") does NOT hash the password which is problemating when comparing submitted (and hashed) passwords. register_user(**self.userdata) self.client.post('/test_login', data={'id': 1})