func LoginPost(ctx *gin.Context) { // create a new Beego ORM object o := orm.NewOrm() o.Using("default") // initialize our data structs data := LoginData{} user := models.Users{} // expecting our login data in JSON form ctx.EnsureBody(&data) // search the users table for the first user with an email and password we supplied // of course storing passwords in plaintext is stupid, this is just an example err := o.QueryTable("users").Filter("email", data.Email).Filter("password", data.Password).One(&user) if err != nil { ctx.String(400, "User was not found!") return } // this data will be added to the cookie and available on decode extra := map[string]string{"email": data.Email} // log in the user err1 := auth.Login(ctx, extra) if err1 == nil { ctx.String(200, "") } }