Use pointer instead of struct

This commit is contained in:
nemunaire 2021-03-07 12:39:38 +01:00
commit 6d8f38d749
18 changed files with 187 additions and 142 deletions

View file

@ -27,7 +27,7 @@ func init() {
router.POST("/api/auth/logout", apiRawHandler(logout))
}
func validateAuthToken(s adlin.Student, _ httprouter.Params, _ []byte) (interface{}, error) {
func validateAuthToken(s *adlin.Student, _ httprouter.Params, _ []byte) (interface{}, error) {
return s, nil
}
@ -50,7 +50,7 @@ type loginForm struct {
}
func completeAuth(w http.ResponseWriter, username string, session *adlin.Session) (err error) {
var std adlin.Student
var std *adlin.Student
if !adlin.StudentExists(username) {
if std, err = adlin.NewStudent(username); err != nil {
return err
@ -60,9 +60,7 @@ func completeAuth(w http.ResponseWriter, username string, session *adlin.Session
}
if session == nil {
var s adlin.Session
s, err = std.NewSession()
session = &s
session, err = std.NewSession()
} else {
_, err = session.SetStudent(std)
}