Login and Signup Pages
Learn to create login and signup pages for authentication in a Beego project
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
:
package controllersimport (beego "github.com/beego/beego/v2/server/web")type SessionsController struct {beego.Controller}
Let’s break down this code:
Lines 7–9: This code defines a struct named
SessionsController
. The struct embedsbeego.Controller
, which means that theSessionsController
inherits methods and properties from thebeego.Controller
type. This enablesSessionsController
to utilize Beego’s functionality for handling ...