great
This commit is contained in:
parent
66884c64bb
commit
4b8230c1ff
18 changed files with 29 additions and 23 deletions
|
|
@ -1,3 +1,3 @@
|
||||||
# order tracking app for a pastry shop
|
# order tracking app for a pastry shop
|
||||||
|
|
||||||
I don't remember what iroon stood for
|
I don't remember what cake-order-tracker stood for
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/models"
|
"github.com/Bronku/cake-order-tracker/models"
|
||||||
"github.com/Bronku/iroon/store"
|
"github.com/Bronku/cake-order-tracker/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Authenticator struct {
|
type Authenticator struct {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package auth
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/crypto"
|
"github.com/Bronku/cake-order-tracker/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *Authenticator) verifyCredentials(login, password string) error {
|
func (a *Authenticator) verifyCredentials(login, password string) error {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/models"
|
"github.com/Bronku/cake-order-tracker/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *Authenticator) getSession(r *http.Request) (models.Token, error) {
|
func (a *Authenticator) getSession(r *http.Request) (models.Token, error) {
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/crypto"
|
"github.com/Bronku/cake-order-tracker/crypto"
|
||||||
"github.com/Bronku/iroon/models"
|
"github.com/Bronku/cake-order-tracker/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *Authenticator) newSession(user string) (http.Cookie, error) {
|
func (a *Authenticator) newSession(user string) (http.Cookie, error) {
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -1,4 +1,4 @@
|
||||||
module github.com/Bronku/iroon
|
module github.com/Bronku/cake-order-tracker
|
||||||
|
|
||||||
go 1.23.5
|
go 1.23.5
|
||||||
|
|
||||||
|
|
|
||||||
8
main.go
8
main.go
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/auth"
|
"github.com/Bronku/cake-order-tracker/auth"
|
||||||
"github.com/Bronku/iroon/logging"
|
"github.com/Bronku/cake-order-tracker/logging"
|
||||||
"github.com/Bronku/iroon/server"
|
"github.com/Bronku/cake-order-tracker/server"
|
||||||
"github.com/Bronku/iroon/store"
|
"github.com/Bronku/cake-order-tracker/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/models"
|
"github.com/Bronku/cake-order-tracker/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func monthInterval(y int, m time.Month) (firstDay, lastDay time.Time) {
|
func monthInterval(y int, m time.Month) (firstDay, lastDay time.Time) {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/models"
|
"github.com/Bronku/cake-order-tracker/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *Server) postCake(r *http.Request) (any, int, error) {
|
func (h *Server) postCake(r *http.Request) (any, int, error) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/store"
|
"github.com/Bronku/cake-order-tracker/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/logging"
|
"github.com/Bronku/cake-order-tracker/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed templates/*
|
//go:embed templates/*
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/models"
|
"github.com/Bronku/cake-order-tracker/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Store) cakeCount() int {
|
func (s *Store) cakeCount() int {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package store
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -27,6 +28,11 @@ func (s *Store) loadFile(file string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("error executing migration: ", file, err)
|
log.Fatal("error executing migration: ", file, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err = s.db.Exec(fmt.Sprintf("PRAGMA user_version = %d;", version))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("error setting user_version:", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) loadMigrations() {
|
func (s *Store) loadMigrations() {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/models"
|
"github.com/Bronku/cake-order-tracker/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// #todo update labels in templates
|
// #todo update labels in templates
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package store
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/models"
|
"github.com/Bronku/cake-order-tracker/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Store) AddSession(token, userName string, expiration time.Time) error {
|
func (s *Store) AddSession(token, userName string, expiration time.Time) error {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/models"
|
"github.com/Bronku/cake-order-tracker/models"
|
||||||
_ "github.com/knaka/go-sqlite3-fts5"
|
_ "github.com/knaka/go-sqlite3-fts5"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/models"
|
"github.com/Bronku/cake-order-tracker/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStore(t *testing.T) {
|
func TestStore(t *testing.T) {
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ package store
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/Bronku/iroon/crypto"
|
"github.com/Bronku/cake-order-tracker/crypto"
|
||||||
"github.com/Bronku/iroon/models"
|
"github.com/Bronku/cake-order-tracker/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Store) AddUser(login, password string) error {
|
func (s *Store) AddUser(login, password string) error {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue