diff --git a/.vscode/launch.json b/.vscode/launch.json index 87c8edd..69ae210 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -16,7 +16,7 @@ "request": "attach", "mode": "remote", "port": 4321, - "host": "45.76.84.7", + "host": "152.53.236.243", } ] } \ No newline at end of file diff --git a/alfheim-website.service b/alfheim-website.service index c1ae528..3c587e5 100644 --- a/alfheim-website.service +++ b/alfheim-website.service @@ -15,8 +15,8 @@ CapabilityBoundingSet=CAP_NET_BIND_SERVICE AmbientCapabilities=CAP_NET_BIND_SERVICE EnvironmentFile=/etc/environment WorkingDirectory=/home/alfheim/linux_amd64 -#ExecStart=/go/bin/dlv --listen=:4321 --headless=true --log=true exec /home/alfheim/linux_amd64/alfheim-website -- -production -ExecStart=/home/alfheim/linux_amd64/alfheim-website -production +ExecStart=/home/alfheim/go/bin/dlv --listen=:4321 --headless=true --log=true exec /home/alfheim/linux_amd64/alfheim-website -- -production +#ExecStart=/home/alfheim/linux_amd64/alfheim-website -production Restart=on-failure RestartSec=5 diff --git a/bin/alfheim-website b/bin/alfheim-website index 4427ae2..7eec309 100755 Binary files a/bin/alfheim-website and b/bin/alfheim-website differ diff --git a/bin/linux_amd64/alfheim-website b/bin/linux_amd64/alfheim-website index c1bd5fb..8b873d9 100755 Binary files a/bin/linux_amd64/alfheim-website and b/bin/linux_amd64/alfheim-website differ diff --git a/handlers.go b/cmd/web/handlers.go similarity index 97% rename from handlers.go rename to cmd/web/handlers.go index 0471d12..92a22b7 100644 --- a/handlers.go +++ b/cmd/web/handlers.go @@ -23,6 +23,8 @@ import ( "github.com/stripe/stripe-go/v78/price" "github.com/stripe/stripe-go/v78/subscription" "github.com/stripe/stripe-go/v78/webhook" + + "alfheimgame.com/alfheim/pkg/models" ) //import "strconv" @@ -30,7 +32,7 @@ import ( type TemplateData struct { AuthenticatedUser int32 FormErrors map[string]string - Account Account + Account models.Account Prices []stripe.Price ClientSecret string ActiveSubscription bool @@ -151,7 +153,7 @@ func login(w http.ResponseWriter, r *http.Request) { } id, err := users.Authenticate(username, password) - if err == ErrInvalidCredentials { + if err == models.ErrInvalidCredentials { errors["generic"] = "Email or Password is incorrect" err := text.Execute(w, TemplateData{AuthenticatedUser: authenticated_user(w, r), FormErrors: errors}) if err != nil { @@ -231,7 +233,7 @@ func register(w http.ResponseWriter, r *http.Request) { } case http.MethodPost: - account := Account{Username: r.FormValue("username"), Password: []byte(r.FormValue("password")), Firstname: r.FormValue("firstname"), Lastname: r.FormValue("lastname"), Email: r.FormValue("email")} + account := models.Account{Username: r.FormValue("username"), Password: []byte(r.FormValue("password")), Firstname: r.FormValue("firstname"), Lastname: r.FormValue("lastname"), Email: r.FormValue("email")} errors := make(map[string]string) @@ -258,7 +260,7 @@ func register(w http.ResponseWriter, r *http.Request) { _, err := users.Insert(account.Username, string(account.Password), account.Firstname, account.Lastname, account.Email) - if err == ErrDuplicateEmail || err == ErrDuplicateUsername { + if err == models.ErrDuplicateEmail || err == models.ErrDuplicateUsername { } else if err != nil { diff --git a/main.go b/cmd/web/main.go similarity index 94% rename from main.go rename to cmd/web/main.go index 38ccef7..c428c05 100644 --- a/main.go +++ b/cmd/web/main.go @@ -15,10 +15,12 @@ import ( "github.com/gorilla/sessions" _ "github.com/lib/pq" "github.com/stripe/stripe-go/v78" + + "alfheimgame.com/alfheim/pkg/models" ) -var users *Usermodel -var subscriptions *SubscriptionModel +var users *models.Usermodel +var subscriptions *models.SubscriptionModel var key = []byte("super-secret-key") var store = sessions.NewCookieStore(key) @@ -45,8 +47,8 @@ func main() { } defer db.Close() - users = &Usermodel{db} - subscriptions = &SubscriptionModel{db} + users = &models.Usermodel{db} + subscriptions = &models.SubscriptionModel{db} mux := http.NewServeMux() diff --git a/middleware.go b/cmd/web/middleware.go similarity index 100% rename from middleware.go rename to cmd/web/middleware.go diff --git a/go.mod b/go.mod index e879a5c..0686713 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,16 @@ module alfheimgame.com/alfheim -go 1.22.2 +go 1.25.1 require ( github.com/alexedwards/argon2id v1.0.0 github.com/gorilla/sessions v1.2.2 github.com/lib/pq v1.10.9 github.com/stripe/stripe-go/v78 v78.7.0 - golang.org/x/crypto v0.33.0 ) require ( github.com/gorilla/securecookie v1.1.2 // indirect - golang.org/x/net v0.21.0 // indirect + golang.org/x/crypto v0.33.0 // indirect golang.org/x/sys v0.30.0 // indirect - golang.org/x/text v0.22.0 // indirect ) diff --git a/go.sum b/go.sum index 6b08b7b..8a1ff8a 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,6 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -47,8 +45,6 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -63,8 +59,6 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/models.go b/pkg/models/models.go similarity index 99% rename from models.go rename to pkg/models/models.go index 2f8beea..93ffce8 100644 --- a/models.go +++ b/pkg/models/models.go @@ -2,7 +2,7 @@ // Created by vfs on 02.05.2024. // -package main +package models import ( "database/sql" diff --git a/ui/account.html b/ui/html/account.html similarity index 100% rename from ui/account.html rename to ui/html/account.html diff --git a/ui/base.html b/ui/html/base.html similarity index 100% rename from ui/base.html rename to ui/html/base.html diff --git a/ui/index.html b/ui/html/index.html similarity index 100% rename from ui/index.html rename to ui/html/index.html diff --git a/ui/login.html b/ui/html/login.html similarity index 100% rename from ui/login.html rename to ui/html/login.html diff --git a/ui/logout.html b/ui/html/logout.html similarity index 100% rename from ui/logout.html rename to ui/html/logout.html diff --git a/ui/register.html b/ui/html/register.html similarity index 100% rename from ui/register.html rename to ui/html/register.html diff --git a/ui/subscribe.html b/ui/html/subscribe.html similarity index 100% rename from ui/subscribe.html rename to ui/html/subscribe.html diff --git a/ui/subscribe_stripe.html b/ui/html/subscribe_stripe.html similarity index 100% rename from ui/subscribe_stripe.html rename to ui/html/subscribe_stripe.html diff --git a/static/Vollkorn-VariableFont_wght.ttf b/ui/static/Vollkorn-VariableFont_wght.ttf similarity index 100% rename from static/Vollkorn-VariableFont_wght.ttf rename to ui/static/Vollkorn-VariableFont_wght.ttf diff --git a/static/image.png b/ui/static/image.png similarity index 100% rename from static/image.png rename to ui/static/image.png diff --git a/static/login_24dp_FILL0_wght400_GRAD0_opsz24.svg b/ui/static/login_24dp_FILL0_wght400_GRAD0_opsz24.svg similarity index 100% rename from static/login_24dp_FILL0_wght400_GRAD0_opsz24.svg rename to ui/static/login_24dp_FILL0_wght400_GRAD0_opsz24.svg diff --git a/static/panel-000.png b/ui/static/panel-000.png similarity index 100% rename from static/panel-000.png rename to ui/static/panel-000.png diff --git a/static/style.css b/ui/static/style.css similarity index 100% rename from static/style.css rename to ui/static/style.css diff --git a/static/video.mp4 b/ui/static/video.mp4 similarity index 100% rename from static/video.mp4 rename to ui/static/video.mp4