miguelgrinberg / flasky

Companion code to my O'Reilly book "Flask Web Development", second edition.
MIT License
8.52k stars 4.21k forks source link

Account confirming problem #270

Closed butflame closed 7 years ago

butflame commented 7 years ago

Hi Mr.Grinberg & everyone: I've got an issue about account comfirming: When I click the link from the email sent by my webapp, but failed comfirming: The webpage flashed 'You have confirmed your account. Thanks! ',BUT the url was still '/auth/unconfirmed', and I check the data through sqlite3, the value of myaccount.confirmed = 0. I tried several times sending emails and click the link to confirm , but never succeeded. You can check my repositories named 'FLAPP' for further information, it's generally same as tag-8e. Hope u can answer this.

miguelgrinberg commented 7 years ago

What version of Flask are you using?

You may want to read issue #58 to see if the problem you are seeing is the same. That is a bug in Flask, but that bug should be fixed in the 0.12.x releases.

butflame commented 7 years ago

Well , here's my requirements about this, Flask==0.12 Flask-SQLAlchemy==2.2

I've checked issue #58 , and add a commit action, like this: def confirm(self,token): s = Serializer(current_app.config['SECRET_KEY']) try: data = s.loads(token) except: return False if data.get('confirm') != self.id: return False self.confirmed = True db.session.add(self) db.session.commit() return True

And it's OK now. BUT I'm not sure whether this would happen in other case or not…… Thanks miguel!

butflame commented 7 years ago

Sorry……I figured out , flask0.12 had fixed this bug. I made a mistake in config.py , missed one letter(TEARDON instead of TEARDOWN). After correct this , the app runs well.