Building user management in WikiFlux so it will be multi-user. And putting in Stripe subscription setup.
What kinda flow do I want?
Oct12
pip install Flask-User → successalter the users table schema.
role feature? Or do something nastier to limit admin rights to my 1 user?users table, make a SQL script I can run later in prod. Actually 2 bits, because have to modify the existing record before adding constraints. They're saved in file, but I ran them in command-line.models.pyclass User(Base, UserMixin):
NameError: name 'UserMixin' is not defined
'No Flask-SQLAlchemy, Flask-MongoEngine or Flask-Flywheel installed and no Pynamo Model in use.'\
flask_user.ConfigError: No Flask-SQLAlchemy, Flask-MongoEngine or Flask-Flywheel installed and no Pynamo Model in use. You must install one of these Flask extensions.
db = SQLAlchemy(app) but that probably requires a bunch of other changes. Maybe need to find some more example Flask apps, conform my code?db_manager code to assume it's sqlalchemyOct18
bill@simplest-thing.com
/members route/members get sign-in page; enter info I had pushed into db before → get error, derp I added column email_confirmed should be email_confirmed_atALTER TABLE to fix column; hit again → UnknownHashError: hash could not be identified hmm not lots of help therebill@simplest-thing.com → AttributeError: 'scoped_session' object has no attribute 'session'db.session. into db.null value in column "id" of relation "users" violates not-null constraintserial? How convert to that? Nope, user more SQL-compliant identity/generatedid field then add the new typecreate sequenceOct19
Oct20
/register, now get an error about form object for hidden_tag - research says that's for WTForms which is for CSRF protection, so I should be doing that anyway.pip install flask-wtf → I think it was automatically installed by flask-userform.validate_on_submit() part - dies hardOct21
validate yeah it fails in there{{ form.csrf_token }} in my form, boom!Oct22
Oct23
validate_and_submit() does the job, appear not.populate_obj()was a class (models.User) supplied where an instance was required? - just needed parensOct25
print user says the populate_obj() call isn't actually doing anything....commit!username is empty, despite form... (which then triggers uniqueness issue)Oct26
Oct27
form.populate_obj(user) - now getting fields except for username againMyRegisterForm() - didn't help, took it back outNov01
Plan: I'm going to suck it up and upgrade to current Flask, then restructure in line with this
Nov03
pip install --upgrade Flask no complaints. Runs fine!app in there. I'm not putting the venv down at that level. But I will make an app subdirectory of my app's directorywikiweb.py above app with just from app import app__init__.py inside app with the app = Flask(__name__) and similar bitswikiweb.py to routes.py. Rip out the main caller bits, swap in from app import app for past app-import bits.flask run → flask_user.ConfigError: Config setting USER_EMAIL_SENDER_EMAIL is missing. even though it's there in the routes.py file. Should probably move some config stuff around.config.py above /app/flask run → launches! Hit page - works!pip install python-dotenv and make .flaskenv file. Still runstemplates subdirectory with templates, and they are working since my pages are loading.WTForms, but maybe now's a good time to play with that directly for a non-user/login form...form.validate() was false, with form.errors = {'body': [u'This field is required.']}Nov04
validate_on_submit() so that if validation fails they can treat it like a GET and deliver the form. Would need nice error handling, but that kinda makes sense....flash if validate failNov05
db instead of db_session, stop importing the database.py file that calls scoped_session, move config bits into config.pyuser_manager = CustomUserManager(app, db, User) because db is not defined - suspect this is part of the kludging I did to get flask-user working, so will go back to their raw instructions....__init__.pydb not defined - still need a from app import db in routes.py'SQLAlchemy' object has no attribute 'commit'db.commit() to db.session.commit() → no error, but it also doesn't actually save the change!SQLALCHEMY_COMMIT_ON_TEARDOWN = True to config.py → edits seem to save, but
<p> tags?!?db.add(node) → 'SQLAlchemy' object has no attribute 'add'db.session.add(node) → savesNov06: what's with the <p> tags?
action value cases, falling into a last case I just use for remote-POST, and therefore not setting modified.response.form shows I have 2 action entries, one of which is empty?!?action is a bad idea? (It hasn't been an issue in the past. But maybe doesn't play well somewhere in magic now....)HiddenField in my forms.py class?!? (Since my template is old, all the fields in it are explicitNov11
StringField instead of HiddenField - now setting ModifiedNov12
USER_ENABLE_EMAIL and USER_ENABLE_USERNAME config settings... do you have to set just 1 or the other? Does me having u_e_u set to False cause the code to ignore the form field?UnknownHashError: hash could not be identifiedSMTP Connection error: Check your MAIL_SERVER and MAIL_PORT settingsFlask-Mail SMTP server settings → email sends, I receive it'SQLAlchemy' object has no attribute 'commit'Nov16:
flask-user sql_db_adaptor.py to use db.session.commit() - had changed that when I was first trying to get flask-user working weeks ago.Your account has not been enabled.)Your account has not been enabled. I'm guessing that's because db users.active is nullFlask-Login instead of Flask-User grrr0.0.0.0. Done.AND syntaxspaces upon creating the user./private and /wiki for their space names, it becomes unnecessary. (Or I could invent new defaults for everyone else, like /garden instead of /wiki, and handle mine as a special exception.)spaces.path is redundant to users.subdomainspaces.id is foreign key in nodes.space_id, so I'd need to refactor that. And maybe I'll want to offer some people a 3rd space, etc.spaces.path to refer to the url-path rather than the subdomainspaces.privacy_typeNov17
hosts file because it doesn't support DNS wildcards for subdomainsSERVER_NAME for domain into config (I think)http://flux.garden:5000/static/bill2009_152.png - or, if I add a subdomain, then it gets picked up by one of my routes!hosts file, I left out the raw-domain case! So once I added that line to my hosts file, all good!Nov18
NameError: global name 'is_anonymous' is not defined. Derp, that's User.is_anonymous/user/sign-in but that is still within the subdomain, so it gets grabbed by the route and fails - need to redirect to the raw-domain. Ah, should use url_for.... ah, arg for that needs to be in quotes. Now good!User.is_anonymous, it's current_user.is_anonymous - I thought that smelled wrong. Now it's good.edit link to render. Change to use is_authenticated, generates link but it's wrong. Running into issues with using subdomain model.render_template() → link in template url_for('node_edit', page_url=page_url, path=path, subdomain=subdomain) rendered to http://flux.garden:5000/private/2019-09-05-Jangly/edit?subdomain=webseitzNov20
url_for issue, so just making my own relative URL reference. Works.logged_in() conditional, fix functions to for new args, etc. → get formNov22
Nov23
favicon.ico is getting picked up by routes other than static, even though other static images aren't having that issue, and this file wasn't an issue with user_id=1.lower() wrapper, fixed that.127.0.0.1 - - [23/Nov/2020 11:12:29] "GET /favicon.ico HTTP/1.1" 308 -
127.0.0.1 - - [23/Nov/2020 11:12:29] "GET /favicon.ico/ HTTP/1.1" 308 -
[2020-11-23 11:12:29,086] ERROR in app: Exception on /favicon.ico/FrontPage [GET]
Nov24
Nov28
Nov29
Dec01
e-content style from default.css, while the normal/expected is getting that overridden by cherwell.cssDec01
What's left?
is_activeDec11
form.inner_path instead of user.inner_pathdb.session.add(outer) (and commit) instead of outer.save() - so try changing it. No difference.Dec13
print statements haven't been doing anything the last couple days.... Nope still not print ouput.log_statement. Stop/start service. Nope, no insert-space queries - so there's not an error there that's not getting passed back.Dec14
Dec15
tachyondecay at discord noted the key relationship line in my models.py was commented out. Probably during early-state problems. Uncommenting, plus tweaking: spaces = relationship('Space', backref='owner', lazy=True). Also adding SqlAlchemy_echo to config. Nope still only inserting user.2020-12-15 19:49:54,563 INFO sqlalchemy.engine.base.Engine SELECT users.id AS users_id, users.username AS users_username, users.subdomain AS users_subdomain, users.email AS users_email, users.email_confirmed_at AS users_email_confirmed_at, users.password AS users_password, users.active AS users_active, users.first_name AS users_first_name, users.last_name AS users_last_name
FROM users
WHERE users.username ILIKE %(username_1)s
LIMIT %(param_1)s
2020-12-15 19:49:54,563 INFO sqlalchemy.engine.base.Engine {'param_1': 1, 'username_1': u'Test14'}
2020-12-15 19:49:54,588 INFO sqlalchemy.engine.base.Engine SELECT users.id AS users_id, users.username AS users_username, users.subdomain AS users_subdomain, users.email AS users_email, users.email_confirmed_at AS users_email_confirmed_at, users.password AS users_password, users.active AS users_active, users.first_name AS users_first_name, users.last_name AS users_last_name
FROM users
WHERE users.email ILIKE %(email_1)s
LIMIT %(param_1)s
2020-12-15 19:49:54,588 INFO sqlalchemy.engine.base.Engine {'email_1': u'fluxent+14@gmail.com', 'param_1': 1}
2020-12-15 19:49:54,855 INFO sqlalchemy.engine.base.Engine INSERT INTO users (username, subdomain, email, email_confirmed_at, password, active, first_name, last_name) VALUES (%(username)s, %(subdomain)s, %(email)s, %(email_confirmed_at)s, %(password)s, %(active)s, %(first_name)s, %(last_name)s) RETURNING users.id
2020-12-15 19:49:54,855 INFO sqlalchemy.engine.base.Engine {'username': u'Test14', 'first_name': u'Test14', 'last_name': u'Test14', 'email_confirmed_at': None, 'password': '$2b$12$o6A8jDSA6vwsBYGqrUMHQO7uFzqovXqRcP3Pfv5Ah7NawcYY86aRa', 'active': True, 'subdomain': u'Test14', 'email': u'fluxent+14@gmail.com'}
2020-12-15 19:49:54,857 INFO sqlalchemy.engine.base.Engine COMMIT
2020-12-15 19:49:54,858 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2020-12-15 19:49:54,858 INFO sqlalchemy.engine.base.Engine SELECT users.id AS users_id, users.username AS users_username, users.subdomain AS users_subdomain, users.email AS users_email, users.email_confirmed_at AS users_email_confirmed_at, users.password AS users_password, users.active AS users_active, users.first_name AS users_first_name, users.last_name AS users_last_name
FROM users
WHERE users.id = %(param_1)s
appdirs==1.4.4
configparser==4.0.2
contextlib2==0.6.0.post1
distlib==0.3.1
filelock==3.0.12
httplib2==0.18.1
importlib-metadata==2.0.0
importlib-resources==3.0.0
oauth2==1.9.0.post1
pathlib2==2.3.5
scandir==1.10.0
singledispatch==3.4.0.3
six==1.15.0
typing==3.7.4.3
virtualenv==20.0.32
zipp==1.2.0
register method isn't even being called, but that the default Flask-User view is being used! Derp of the year. Really questioning whether I want to keep this magic, or switch to Flask-Login...Dec18
Flask-User and go with Flask-LoginCustomUserManager and modify it therefrom flask import bitsalter sequence spaces_id_seq restart with 5 - sets last_value=5 - which will actually be the next valueglobal name 'signals' is not defined - add signals to from flask import lineAttributeError: 'module' object has no attribute 'user_registered' - also associated with signal. Decide to just delete that line, since I don't think I'll need signals.USER_AFTER_REGISTER_ENDPOINT = 'user.login' in confighome page post-login to check user status (paid, confirmed). so set USER_AFTER_LOGIN_ENDPOINT = 'home'Dec19
home pageYour account has not been enabled.Dec20
next argument from Flask-Login doesn't nicely handle subdomains. Or maybe I'm doing it wrong. See discussion.
url_for and subdomainsapp.url_build_error_handlers.append(external_url_handler)Dec21
create_checkout_session, create routes for pay_success and pay_cancel
/flask_user/script.js into static - but what calls it? Does Stripe just assume it's at root? Might have to move it.invoice_paid etc
user.active.env file for environment variables, and use python-dotenv to load them
.flaskenv for Flask CLI configuration, like FLASK_APP etc (find put those in our .flaskenv file in article), and use .env file for passwords and suchscript.js, this article has main.js which seems to be the same (and is in static), so I'm renaming mine to stripe.jsDec22
active then he doesn't get logged in, so no current_user defined, etc. Which doesn't work for passing along email to Stripe, etc. Which makes it smell like
USER_ALLOW_LOGIN_WITHOUT_CONFIRMED_EMAIL=False to put that block in placehomeusers.permitted field to track whether confirmed and current-paid
invoice.paid or invoice.payment_failed events to my webhookcheckout.session.completed event I set users.permitted=Trueinvoice.paid I set users.permitted=Trueinvoice.payment_failed I set users.permitted=False - I don't have to track when last-payment made, when due for next payment, etc., Stripe does all that for me.customer.subscription.deleted (means they canceled), set users.permitted=FalsecustomerId on the users table or the payment_events table? This tutorial makes a stripe_customers table - but won't I have 1:1 from User to StripeCustomer? And both 1:1 to Subscription? Or maybe if someone changes payment-model they get a different SubscriptionId? I guess I'll follow that model: table payment_customersevents, I think.
source aboveDec26
models.py, sql schema per aboveJan03
USER_AFTER_CONFIRM_ENDPOINT = 'user.login'
USER_AFTER_RESEND_EMAIL_CONFIRMATION_ENDPOINT = 'user.login'
/home (because have USER_AUTO_LOGIN = True)<button id="checkout"> and clicking it does nothing.monthly-btn and yearly-btn.env file put MONTHLY_PRICE_ID and YEARLY_PRICE_ID API Ids that Stripe assignsroutes.py I define @app.route("/setup")... def get_publishable_key(): to return those Price IDsstripe.js (which I renamed from their script.js) to fetch the appropriate price-id and redirect to Stripe.home.html template needs to reference the 2 JavaScript files - I had only done this for login.htmlstripe.js loads that file fine..../setup in the console getting called and returning the price-idsUncaught (in promise) IntegrationError: Invalid value for Stripe(): apiKey should be a string. You specified: undefined. Ah, I was returning publicKey instead of publishableKey.
/create_checkout_session route is giving a 400
"global name 'CHECKOUT_SESSION_ID' is not defined" (I went into chrome dev/devtools, picked "network", then clicked on the red create-checkout-session)try - move variable-setting bits outside, confirm issue is global name 'CHECKOUT_SESSION_ID' is not defined when trying to attach it to success_urlurl_for and usesuccess_url = app.config["SERVER_PROTOCOL"] + app.config["SERVER_NAME"] +'/pay_success?{CHECKOUT_SESSION_ID}'
→ works!
Feb06 getting my Linode server caught up
pip install --upgrade Flask → lots of warning about InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.pip install --upgrade pip → Successfully installed pip-21.0.1 (with same warnings)pip install pyOpenSSL ndg-httpsclient pyasn1, → sys.stderr.write(f"ERROR: {exc}").... SyntaxError: invalid syntax which is not surprising: pip 21.0 dropped support for Python 2.7 and Python 3.5. Hmm maybe I'll downgrade to pip 20.3.4... → invalid syntaxpython get-pip.py → invalid syntax?!?! Ah tried again with 2.7-specific flag, now seems ok (though still giving the original urllib3/ssl InsecurePlatformWarning)pip install pyOpenSSL ndg-httpsclient pyasn1 - get warnings during the install, unclear whether it matters. Going to move forward....Feb07
pip install python-dotenv → successful, but with InsecurePlatformWarningpip install Flask-User → Couldn't find index page for 'Flask-Login' (maybe misspelled?)pip install Flask-Login → Successfully installed Flask-Login-0.5.0pip install Flask-User again → same error (2nd line is No local packages or download links found for Flask-Login - which is why I thought installing Flask-Login directly itself would solve the problem)dist-packages shows flask_login and Flask_Login-0.5.0.dist-infopip install Flask-User --no-dependencies → same errorFork
Now what?
May14
/webhook, so I rename it.stripe login pairingstripe listen --forward-to flux2.garden:5000/stripewebhook → get secret, add to .env, add equiv to stripe_keys. Do flask run.active and email_confirmed_at but not permitted, log in as that user. Get redirected to page saying "Note that your account isn't active until you have paid". Press a button... get Stripe payment page. Fill in fake number, submit... → see lots of events in CLI window. But they all have 404. Likewise the flask window shows 4 POST with 404 responses. Derp realized that stripe listen command was missing underscore in stripe_webhook. Quit, re-do forward-to, have same signing hook.webhook_secret and endpoint_secret - decide to stick with the latter.2021-05-14 22:13:40 --> checkout.session.completed [evt_1IrDwaEl5VTchHIeCX0IZlgN]
2021-05-14 22:13:40 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IrDwaEl5VTchHIeCX0IZlgN]
2021-05-14 22:13:41 --> customer.subscription.updated [evt_1IrDwaEl5VTchHIe0jI46uQ1]
2021-05-14 22:13:41 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IrDwaEl5VTchHIe0jI46uQ1]
2021-05-14 22:13:41 --> invoice.payment_succeeded [evt_1IrDwaEl5VTchHIe2f0f2pKr]
2021-05-14 22:13:41 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IrDwaEl5VTchHIe2f0f2pKr]
2021-05-14 22:13:41 --> payment_intent.succeeded [evt_1IrDwbEl5VTchHIekBQdxaz7]
2021-05-14 22:13:41 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IrDwbEl5VTchHIekBQdxaz7]
2021-05-14 22:13:44 --> invoice.created [evt_1IrDwaEl5VTchHIewc6lt6F0]
2021-05-14 22:13:44 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IrDwaEl5VTchHIewc6lt6F0]
2021-05-14 22:13:46 --> invoice.paid [evt_1IrDwaEl5VTchHIeqXyyT2vt]
2021-05-14 22:13:46 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IrDwaEl5VTchHIeqXyyT2vt]
2021-05-14 22:22:30 --> checkout.session.completed [evt_1IrE59El5VTchHIenK6L6qR4]
2021-05-14 22:22:30 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IrE59El5VTchHIenK6L6qR4]
2021-05-14 22:22:31 --> invoice.updated [evt_1IrE5AEl5VTchHIeOWNm1zC5]
2021-05-14 22:22:31 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IrE5AEl5VTchHIeOWNm1zC5]
2021-05-14 22:22:31 --> invoice.updated [evt_1IrE5AEl5VTchHIeDEK3xmdR]
2021-05-14 22:22:31 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IrE5AEl5VTchHIeDEK3xmdR]
2021-05-14 22:22:32 --> invoice.paid [evt_1IrE5AEl5VTchHIenIHYb4Jk]
2021-05-14 22:22:32 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IrE5AEl5VTchHIenIHYb4Jk]
2021-05-14 22:22:34 --> customer.subscription.created [evt_1IrE5AEl5VTchHIe1PKCysGc]
2021-05-14 22:22:34 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IrE5AEl5VTchHIe1PKCysGc]
May15
PaymentCustomer table (1 row per customer-purchase, so at least for now just 1 row per paid customer) and Event table (for all these payment events).http://flux2.garden:5000/pay_success?{CHECKOUT_SESSION_ID} in my flask console, which smells like I have an un-rendered variable somewhere... but looking at my test user I do see a real value in the URL, so maybe that logging is just early/wrong.checkout.session.completed
"customer": "cus_JUCUsNGO3AJZXx"customer_email ah right you can't change that value over at Stripe, so I don't have to worry about it not matching."id": "cs_test_a1ANzAPUI9ELQVbB42i44pM4So7KkejRMyh1BQXW2SC6IcQm6dU6mdJvB8""subscription": "sub_JUCUJW8z7EwNdV"invoice.paid
"customer": "cus_JUCUsNGO3AJZXx" and customer_emailcreated timestamp from Stripe and trying to create Event object, but that wants DateTime passed, so have to convert. Actually, going to ignore what Stripe passes and just take the current-time. Also restructure some loggingcharge.succeeded, and customer_email was buried in a different level. Hmm could the issue be that the customer already exists from prior attempts? Yep they're there. Can delete customers from my dashboard, but not invoices. Delete all → see more webhooks come through, but they also got 500. Partially because the customer_email is just named email in some of these events, jfc. Even the customer ID is sometimes id and sometimes customer, are they really kidding me.object attribute tells you the object type, and the id will be that object-type-id. If the object isn't the customer, then the customer attribute is the customer_id.customer or id.... It sounds like the first event from a new customer/purchase will be checkout.session.completed so that's where I should assume I'm creating a customer, and in the other events assume that I'm looking one up. (At least as a starting point - but I probably have to play it safe and always do a lookup first, then create if not found....May16
checkout.session.completed"object": "checkout.session",
"customer": "cus_JUrckzVGNfP1UT",
"customer_email": "fluxent+hunter@gmail.com",
"subscription": "sub_JUrcPaHNfV8H92",
subscription doesn't already exist), and for all other cases I'll assume customer is customer_id, and look up the PaymentCustomer to get the user_id, and use that for everything.2021-05-16 17:28:20 --> charge.succeeded [evt_1IrsRbEl5VTchHIe1mNO67I3]
2021-05-16 17:28:20 <-- [500] POST http://flux2.garden:5000/stripe_webhook [evt_1IrsRbEl5VTchHIe1mNO67I3]
2021-05-16 17:28:21 --> customer.created [evt_1IrsRbEl5VTchHIeWw8ZY97W]
2021-05-16 17:28:21 <-- [500] POST http://flux2.garden:5000/stripe_webhook [evt_1IrsRbEl5VTchHIeWw8ZY97W]
2021-05-16 17:28:22 --> customer.subscription.created [evt_1IrsRbEl5VTchHIe1daEpL8s]
2021-05-16 17:28:22 <-- [500] POST http://flux2.garden:5000/stripe_webhook [evt_1IrsRbEl5VTchHIe1daEpL8s]
(and many more) - all 500s
charge.succeeded - pmt_customer_id = object['customer'].... TypeError: 'type' object is not subscriptable.... same in othersdata_object=data['object'], so changed that name to objectMay17
2021-05-17 20:14:42 --> payment_method.attached [evt_1IsHWAEl5VTchHIegtef6HZL]
2021-05-17 20:14:42 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IsHWAEl5VTchHIegtef6HZL]
2021-05-17 20:14:42 --> customer.created [evt_1IsHWAEl5VTchHIeMKfCdiWZ]
2021-05-17 20:14:42 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IsHWAEl5VTchHIeMKfCdiWZ]
2021-05-17 20:14:42 --> invoice.updated [evt_1IsHWAEl5VTchHIePFPjhYMc]
2021-05-17 20:14:42 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IsHWAEl5VTchHIePFPjhYMc]
2021-05-17 20:14:42 --> invoice.finalized [evt_1IsHWAEl5VTchHIepEyR6y9j]
2021-05-17 20:14:42 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IsHWAEl5VTchHIepEyR6y9j]
2021-05-17 20:14:43 --> checkout.session.completed [evt_1IsHW9El5VTchHIe5Yn6H6cc]
2021-05-17 20:14:43 <-- [500] POST http://flux2.garden:5000/stripe_webhook [evt_1IsHW9El5VTchHIe5Yn6H6cc]
2021-05-17 20:14:43 --> customer.subscription.updated [evt_1IsHWAEl5VTchHIef8vM3sXn]
2021-05-17 20:14:43 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IsHWAEl5VTchHIef8vM3sXn]
2021-05-17 20:14:43 --> invoice.paid [evt_1IsHWAEl5VTchHIem2zSNx4c]
2021-05-17 20:14:43 --> customer.subscription.created [evt_1IsHWAEl5VTchHIe6RoKt2cG]
2021-05-17 20:14:43 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IsHWAEl5VTchHIe6RoKt2cG]
2021-05-17 20:14:43 <-- [500] POST http://flux2.garden:5000/stripe_webhook [evt_1IsHWAEl5VTchHIem2zSNx4c]
2021-05-17 20:14:43 --> invoice.payment_succeeded [evt_1IsHWAEl5VTchHIeFiELy5no]
2021-05-17 20:14:43 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IsHWAEl5VTchHIeFiELy5no]
(more 200s after)
== instead of = in one of the query.filter_by() clausesalter column id ADD GENERATED for each.checkout.session.completed - and I see Events and PaymentCustomer! (though latter missing created datetime), and user.permitted=True! Success!/home/home redirects to inner space nicely... hmm should I re-consider that, have page with links to inner and outer?May18
May19
/user/sign-in page with msg "A confirmation email has been sent to fluxent+30@gmail.com with instructions to complete your registration."/user/confirm-email/<token>. Click it, get /user/sign-in with 2 messages
/home which wants them to be identified. Or does email-confirm identify them?USER_AFTER_CONFIRM_ENDPOINT = 'user.login' can I change that to home?
USER_AUTO_LOGIN=True set!home - I think it hit home, but that route checks current_user.is_anonymous and bumps user to sign-inUSER_AUTO_LOGIN_AFTER_CONFIRM = TrueMay20
home page with payment buttons. Pay → /pay_success page. That page has links
/home - edit flask_user_layout.html → works
USER_CORPORATION_NAME set? I think there's a default buried in the code, just override in my config.py → all good/home
is_authenticated
May24
permitted2021-05-24 21:45:20 --> invoice.created [evt_1IuqGhEl5VTchHIeJUUwNBCY]
2021-05-24 21:45:20 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IuqGhEl5VTchHIeJUUwNBCY]
2021-05-24 21:45:20 --> customer.subscription.created [evt_1IuqGhEl5VTchHIevKDew47G]
2021-05-24 21:45:20 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IuqGhEl5VTchHIevKDew47G]
2021-05-24 21:45:20 --> invoice.updated [evt_1IuqGhEl5VTchHIeyff2jfgI]
2021-05-24 21:45:20 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IuqGhEl5VTchHIeyff2jfgI]
2021-05-24 21:45:20 --> customer.subscription.updated [evt_1IuqGhEl5VTchHIeK8L49IIK]
2021-05-24 21:45:20 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IuqGhEl5VTchHIeK8L49IIK]
2021-05-24 21:45:20 --> invoice.updated [evt_1IuqGiEl5VTchHIeNcLR7ZHW]
2021-05-24 21:45:20 <-- [200] POST http://flux2.garden:5000/stripe_webhook [evt_1IuqGiEl5VTchHIeNcLR7ZHW]
checkout.session.completed - maybe need to delete old users?May25
INSTALL_RECEIPT.json file pointing to homebrew./usr/local/bin/stripe still points to ../Cellar/stripe/1.5.5/bin/stripe - and there's no 1.6.0 inside Cellar/stripeCellar/stripe/1.5.5... (have to do the security-allow-unsigned Mac thing, but after that it launches fine, and doesn't alert me to update)May26
/home saying email confirmed, signed in successfully, note not active until you've paid/pay_success plus lots of 200 eventsWe can’t connect to the server at flux36.flux2.garden. and console shows a 302hosts file (see Nov17 notes above). Reload → success! Plus db shows correct user record/fields plus 2 events added.Edit to edit/create, title is prefilled with current date instead of correct pagename. That's an old bug I'm finally going to fix now (from when I tried to create a "quick" way to start a new blogbit page)... fixed.git commit way overdue)space so why is it showing - I guess still more places where my ORM query isn't quite right.git commitMay27
mentions into db - hmm doesn't seem to workMay29
Jun02
.env for a change I hadmentions table, and main stuff is working fine.SMTP Connection error: Check your MAIL_SERVER and MAIL_PORT settings. Maybe I have that port blocked? No, it seems like Google is blocking it. Even though Google accepts it fine from my laptop.
Username and Password not accepted.send: 'ehlo [127.0.1.1]\r\n'
reply: b'250-smtp.mxes.net\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-SIZE 104857600\r\n'
reply: b'250-AUTH PLAIN LOGIN\r\n'
reply: b'250-AUTH=PLAIN LOGIN\r\n'
reply: b'250-ENHANCEDSTATUSCODES\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250-DSN\r\n'
reply: b'250 CHUNKING\r\n'
reply: retcode (250); Msg: b'smtp.mxes.net\nPIPELINING\nSIZE 104857600\nAUTH PLAIN LOGIN\nAUTH=PLAIN LOGIN\nENHANCEDSTATUSCODES\n8BITMIME\nDSN\nCHUNKING'
send: 'AUTH PLAIN AGJpbGxfZmx1eGVudC5jb20AeHh4\r\n'
reply: b'535 5.7.8 Error: authentication failed: authentication failure\r\n'
reply: retcode (535); Msg: b'5.7.8 Error: authentication failed: authentication failure'
send: 'AUTH LOGIN YmlsbF9mbHV4ZW50LmNvbQ==\r\n'
reply: b'334 UGFzc3dvcmQ6\r\n'
smtplib.SMTPNotSupportedError: STARTTLS extension not supported by server
send: 'ehlo [127.0.1.1]\r\n'
reply: b'250-smtp.gmail.com at your service, [159.65.175.127]\r\n'
reply: b'250-SIZE 35882577\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\r\n'
reply: b'250-ENHANCEDSTATUSCODES\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-CHUNKING\r\n'
reply: b'250 SMTPUTF8\r\n'
reply: retcode (250); Msg: b'smtp.gmail.com at your service, [159.65.175.127]\nSIZE 35882577\n8BITMIME\nAUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8'
send: 'AUTH PLAIN AGJpbGxAc2ltcGxlc3QtdGhpbmcuY29tAHh4eA==\r\n'
reply: b'535-5.7.8 Username and Password not accepted. Learn more at\r\n'
reply: b'535 5.7.8 https://support.google.com/mail/?p=BadCredentials 42sm2866032qtf.37 - gsmtp\r\n'
reply: retcode (535); Msg: b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials 42sm2866032qtf.37 - gsmtp'
closed, and iptables failed to change that. But I tried doing a telnet on 45 to smtp.gmail.com and it worked fine.Jun04
smtp.googlemail.com so I'll try that → no differenceflask_mail.py → password ='xxx'???envfile_service instead of .env - and she had written some junk in there for passwords. So when I copied .env over it, boom it worked!active (which actually means users.permitted is nullevents table is empty - I think I had to do a schema change there which I never did in production.... yep 2 cases of making id auto-increment, see May17 notes aboveJun05
TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a SignatureVerificationError.events and payment_customers.live mode in Stripe, get my 2 keys and endpoint-secret, update my envfile, restart.Jun07
Jun09
Jun10
/pay_success? with no urg-arg, and it turns out the Manage Billing button doesn't do anything - is it because I don't have that url-arg?Jun11
/pay_success as the home for this?def customer_portal() but no route, and had to add that route to the "Manage Billing" buttonJun12
current_user to drive the portal link, so change code. Now working!Jun15
Jun18
/private!
Jun19
Edited: | Tweet this! | Search Twitter for discussion
Mentions: (2020-10-02) Setting Up Python On New MacBookPro | (2021-02-07) Migrating to Python3 | (2021-03-01) Massive Server Upgrade | (2021-04-25) Move To DigitalOcean | (2021-05-30) Updating WikiGraph Backlinks in Real-time | BackLinks | BlogBit | BootStrap | CLI | CSRF | DNS | FlaskLogin | FlaskUser | Free Trial | Front Page | Getting Started With FluxGarden | HTTPS | Linode | MyPage | Phil Jones | Python | SMTP | Splash Page | SqlAlchemy | SSL | Stripe.com | TuffMail | Twin Pages | Using Stripe Checkout For Your SaaS Subscription | Visible Backlinks | WikiFlux | WikiGraph
Backlinks: (2021-02-07) Migrating to Python3 | (2023-01-01) Can't Reset FluxGarden password | (2023-05-26) Gmail Blocking Some FluxGarden Registration Emails | (2024-04-28) Updating my MacBookPro Python | (2025-12-10) ClaudeCode for TeamGarden | Using Stripe Checkout For Your SaaS Subscription | WikiFlux |