Add user last_seen
This will facilitate maintenance in the future. Running a script to clean the database from dead accounts will now be much easier
This commit is contained in:
parent
e325fdd08a
commit
6bd045ba6b
@ -23,6 +23,7 @@ class User(UserMixin, db.Model):
|
||||
username = db.Column(db.String(64), index=True, unique=True)
|
||||
password_hash = db.Column(db.String(128))
|
||||
posts = db.relationship('Post', backref='author', lazy='dynamic')
|
||||
last_seen = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
|
||||
def __repr__(self):
|
||||
return '<User {}>'.format(self.username)
|
||||
|
@ -369,7 +369,10 @@ def login():
|
||||
flash('Invalid username or password')
|
||||
return redirect(url_for('login'))
|
||||
login_user(user, remember=form.remember_me.data)
|
||||
current_user.last_seen = datetime.datetime.utcnow()
|
||||
db.session.commit()
|
||||
next_page = request.args.get('next')
|
||||
print(current_user.last_seen)
|
||||
if not next_page or url_parse(next_page).netloc != '':
|
||||
next_page = url_for('index')
|
||||
return redirect(next_page)
|
||||
@ -526,6 +529,7 @@ def register():
|
||||
return redirect(url_for('login'))
|
||||
|
||||
return render_template('register.html', title='Register', registrations=REGISTRATIONS, form=form)
|
||||
|
||||
|
||||
@app.route('/error/<errno>')
|
||||
def error(errno):
|
||||
|
Reference in New Issue
Block a user