Beispiel #1
0
    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!')
Beispiel #2
0
    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!')