def run(self): res = sign_up_user(self.username, self.password, self.email) if not res[0]: return error("Unable to add User: {}".format(res[1])) new_user = User() # new_user.user_id = self.username new_user.username = self.username new_user.email = self.email new_user.first_name = self.post_body.get('first_name') new_user.last_name = self.post_body.get('last_name') new_user.phone_number = self.post_body.get('phone_number') new_user.organization = self.post_body.get('organization') print new_user.organization try: new_user.save() except Exception as e: ok = admin_delete_user(self.username) if not ok: return error("Unable to delete User from user pool") return error("Error creating new User: {}".format(e)) debug("SIGNUP_USER", "SUCCESS!") return success( 'User signed up, check your email for confirmation code!')
def run(self): # may be an opportunity to FURTHER abstract out this run step. # even if just for AddUser(). # add to user pool: ok = sign_up_user(self.username, self.password, self.email) if not ok: return error("Unable to add User") # TODO: Implement confirm endpoint/ui flow, then delete ok = admin_confirm_signup(self.username) if not ok: d = admin_delete_user(self.username) if not d: return error("Unable to delete User from user pool") return error("Unable to confirm User") new_user = User() new_user.username = self.username new_user.email = self.email new_user.first_name = self.post_body.get('first_name') new_user.last_name = self.post_body.get('last_name') new_user.phone_number = self.post_body.get('phone_number') new_user.organization = self.post_body.get('organization') print new_user.organization try: new_user.save() except Exception as e: ok = admin_delete_user(self.username) if not ok: return error("Unable to delete User from user pool") return error("Error creating new User: {}".format(e)) debug("ADD_USER", "SUCCESS!") return success('User created!')
def __import_users(): session = session_factory.create_session() if session.query(User).count() > 0: return data_service.get_default_user() user2 = User() user2.email = "*****@*****.**" user2.name = "user 2" session.add(user2) session.commit()
def __import_users(): session = session_factory.create_session() if session.query(User).count() > 0: return data_service.get_default_user() user2 = User() user2.email = '*****@*****.**' user2.name = 'Natalia' session.add(user2) session.commit()
def get_default_user(): session = session_factory.create_session() user = session.query(User).filter(User.email == "*****@*****.**").first() if user: return user user = User() user.name = "Test user 1" user.email = "*****@*****.**" session.add(user) session.commit() return user
def get_default_user(): session = session_factory.create_session() user = session.query(User).filter(User.email == '*****@*****.**').first() if user: return user user = User() user.email = '*****@*****.**' user.name = 'Ruslan' session.add(user) session.commit() return user
def post(self): args = parser.parse_args() session = db_session.create_session() user = User() user.id = args['id'] user.name = args['name'] user.email = args['email'] user.role = args['role'] user.avatar_path = args['avatar_path'] user.set_password(args['password']) session.add(user) session.commit() return jsonify({'message': 'SUCCESS'})
def get_default_user(): session = session_factory.create_session() user = session.query(User).filter(User.email == '*****@*****.**').first() if user: return user user = User() user.email = '*****@*****.**' user.name = 'test user 1' session.add(user) session.commit() return user