Login and Signup Pages
Explore how to create login and signup pages in a Beego web application. Learn to set up routes and controllers for user authentication and build Bootstrap-styled forms for user input. This lesson helps you understand the initial steps of adding secure access to your Golang notes app.
In this lesson, we will start with authenticating the user in the Notes app. Till now, there is no concept of a user in the app. Anyone who knows the URL can access the app and all notes on it.
We will begin by creating sign-up and login pages in the app. These pages will serve as a portal to create a new user and a way to log in for the existing users.
Auth controller
For user sign-up, login, and logout, let’s create a new controller called SessionsController in the file controllers/sessions.go:
Let’s break down this code:
Lines 7–9: This code defines a struct named
SessionsController. The struct embedsbeego.Controller, which means that theSessionsControllerinherits methods and properties from thebeego.Controllertype. This enablesSessionsControllerto utilize Beego’s functionality for handling ...