Compare commits

...

2 Commits

Author SHA1 Message Date
15abdd4081 Added ApplicationData to webservice 2024-02-09 13:22:25 +01:00
f9e49e1145 Update user login time 2024-02-03 10:53:12 +01:00
5 changed files with 9 additions and 0 deletions

View File

@ -231,6 +231,10 @@ func (db *T) SetSessionUser(uuid string, userID int) (err error) { // {{{
} }
return return
} // }}} } // }}}
func (db *T) UpdateUserTime(userID int) (err error) {// {{{
_, err = db.Conn.Exec(`UPDATE _webservice.user SET last_login=NOW() WHERE id=$1`, userID)
return
}// }}}
func (db *T) CreateUser(username, password, name string) (err error) {// {{{ func (db *T) CreateUser(username, password, name string) (err error) {// {{{
_, err = db.Conn.Exec(` _, err = db.Conn.Exec(`

1
go.sum
View File

@ -1,5 +1,6 @@
git.gibonuddevalla.se/go/dbschema v1.2.0 h1:VhHFfkn/4UnlGy2Ax35Po8vb8E/x6DggtvNUKlGGQyY= git.gibonuddevalla.se/go/dbschema v1.2.0 h1:VhHFfkn/4UnlGy2Ax35Po8vb8E/x6DggtvNUKlGGQyY=
git.gibonuddevalla.se/go/dbschema v1.2.0/go.mod h1:BNw3q/574nXbGoeWyK+tLhRfggVkw2j2aXZzrBKC3ig= git.gibonuddevalla.se/go/dbschema v1.2.0/go.mod h1:BNw3q/574nXbGoeWyK+tLhRfggVkw2j2aXZzrBKC3ig=
git.gibonuddevalla.se/go/dbschema v1.3.0/go.mod h1:BNw3q/574nXbGoeWyK+tLhRfggVkw2j2aXZzrBKC3ig=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=

1
pkg.go
View File

@ -207,6 +207,7 @@ func (service *Service) Register(path string, requireSession, requireAuthenticat
} }
} }
service.logger.Info("webserver", "op", "request", "path", r.URL.String())
handler(w, r, sess) handler(w, r, sess)
}) })
} // }}} } // }}}

View File

@ -118,6 +118,7 @@ func (service *Service) sessionAuthenticate(w http.ResponseWriter, r *http.Reque
service.errorHandler(err, "001-A003", w) service.errorHandler(err, "001-A003", w)
return return
} }
service.Db.UpdateUserTime(userID)
} }
authResp, _ := json.Marshal(authResponse) authResp, _ := json.Marshal(authResponse)

View File

@ -14,4 +14,6 @@ type T struct {
UserID int `db:"user_id"` UserID int `db:"user_id"`
Username string Username string
Name string Name string
ApplicationData any
} }