git-svn-id: svn://losandesgames.com/alfheim-website@45 15359d88-9307-4e75-a9c1-e5686e5897df
This commit is contained in:
parent
5b32cd34a2
commit
c15256a9d4
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -16,7 +16,7 @@
|
||||
"request": "attach",
|
||||
"mode": "remote",
|
||||
"port": 4321,
|
||||
"host": "45.76.84.7",
|
||||
"host": "152.53.236.243",
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -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 {
|
||||
|
||||
@ -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()
|
||||
|
||||
6
go.mod
6
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
|
||||
)
|
||||
|
||||
6
go.sum
6
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=
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// Created by vfs on 02.05.2024.
|
||||
//
|
||||
|
||||
package main
|
||||
package models
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 173 B |
Loading…
x
Reference in New Issue
Block a user