You can try this on your own. The results are presented in the following paragraphs.
The view will use the current_user object saved by Flask_login. This current user is already of the User type, so we can directly access its members, such as contributed_repositories and owned_repositories. The full code for the view is as follows:
@app.route('/')
@Flask_login.login_required
def index(*args):
user = Flask_login.current_user
contributed_repositories = user.contributed_repositories.all()
owned_repositories = user.owned_repositories.all()
return render_template(
"index.html",
contributed_repositories=contributed_repositories,
owned_repositories=owned_repositories,
user=user
)
You may have noticed the use of a new function decorator, @Flask_login.login_required. This will check that the user is already logged in before rendering the view. If not, the user...