def delete(self): parser = request.get_json() email = parser.get('email') password = parser.get('password') if email is None or password is None: abort(400) # missing arguments if user_datastore.find_user(email=email) is None: abort(403) # existing user user = user_datastore.find_user(email=email) user_datastore.delete_user(user) return 200
def deleteUser(nickname): """ Delete user account :return: Redirection to index page """ # TODO - Delete associated posts if nickname != current_user.nickname: flash('Wrong user') return redirect(url_for('index')) user = User.query.filter_by(nickname=nickname).first() user_datastore.delete_user(user) user_datastore.commit() return redirect(url_for('index'))