def users_create_default(email, password, id_): """Create default user. This user has the administrator role and can retrieve other user information as well as create new users. """ reana_user_characteristics = { "id_": id_, "email": email, } try: user = User.query.filter_by(**reana_user_characteristics).first() if not user: reana_user_characteristics["access_token"] = secrets.token_urlsafe( 16) user = User(**reana_user_characteristics) create_user_workspace(user.get_user_workspace()) Session.add(user) Session.commit() # create invenio user, passing `confirmed_at` to mark it as confirmed register_user(email=email, password=password, confirmed_at=datetime.datetime.now()) click.echo(reana_user_characteristics["access_token"]) except Exception as e: click.echo("Something went wrong: {0}".format(e)) sys.exit(1)
def users_create_default(email, id_): """Create default user. This user has the administrator role and can retrieve other user information as well as create new users. """ user_characteristics = {"id_": id_, "email": email, } try: user = User.query.filter_by(**user_characteristics).first() if not user: user_characteristics['access_token'] = secrets.token_urlsafe() user = User(**user_characteristics) create_user_workspace(user.get_user_workspace()) Session.add(user) Session.commit() click.echo('Created 1st user with access_token: {}'. format(user_characteristics['access_token'])) except Exception as e: click.echo('Something went wrong: {0}'.format(e)) sys.exit(1)