git-svn-id: svn://losandesgames.com/alfheim-website@37 15359d88-9307-4e75-a9c1-e5686e5897df

This commit is contained in:
Vicente Ferrari Smith 2025-01-01 21:53:07 +00:00
parent 07cdba73e5
commit c911550021
4 changed files with 585 additions and 591 deletions

View File

@ -23,7 +23,7 @@ import "github.com/stripe/stripe-go/v78/webhook"
import "github.com/stripe/stripe-go/v78/customer"
import "github.com/stripe/stripe-go/v78/subscription"
type templatedata struct {
type TemplateData struct {
AuthenticatedUser int32
FormErrors map[string]string
Account Account
@ -86,14 +86,14 @@ func home(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
err := text.Execute(w, templatedata{AuthenticatedUser: id, Account: account, ActiveSubscription: activesubscription})
err := text.Execute(w, TemplateData{AuthenticatedUser: id, Account: account, ActiveSubscription: activesubscription})
if err != nil {
log.Fatal(err)
http.Error(w, "Internal Server Error", 500)
}
case http.MethodPost:
err := text.Execute(w, templatedata{})
err := text.Execute(w, TemplateData{})
if err != nil {
log.Fatal(err)
http.Error(w, "Internal Server Error", 500)
@ -111,7 +111,7 @@ func login(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
err := text.Execute(w, templatedata{})
err := text.Execute(w, TemplateData{})
if err != nil {
log.Fatal(err)
http.Error(w, "Internal Server Error", 500)
@ -137,7 +137,7 @@ func login(w http.ResponseWriter, r *http.Request) {
if len(errors) > 0 {
err := text.Execute(w, templatedata{AuthenticatedUser: authenticated_user(w, r), FormErrors: errors})
err := text.Execute(w, TemplateData{AuthenticatedUser: authenticated_user(w, r), FormErrors: errors})
if err != nil {
log.Fatal(err)
http.Error(w, "Internal Server Error", 500)
@ -149,7 +149,7 @@ func login(w http.ResponseWriter, r *http.Request) {
id, err := users.Authenticate(username, password)
if err == ErrInvalidCredentials {
errors["generic"] = "Email or Password is incorrect"
err := text.Execute(w, templatedata{AuthenticatedUser: authenticated_user(w, r), FormErrors: errors})
err := text.Execute(w, TemplateData{AuthenticatedUser: authenticated_user(w, r), FormErrors: errors})
if err != nil {
log.Fatal(err)
http.Error(w, "Internal Server Error", 500)
@ -181,7 +181,7 @@ func logout(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
err := text.Execute(w, templatedata{AuthenticatedUser: id, Account: account, ActiveSubscription: activesubscription})
err := text.Execute(w, TemplateData{AuthenticatedUser: id, Account: account, ActiveSubscription: activesubscription})
if err != nil {
log.Fatal(err)
http.Error(w, "Internal Server Error", 500)
@ -209,7 +209,7 @@ func register(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
err := text.Execute(w, templatedata{AuthenticatedUser: id, Account: account})
err := text.Execute(w, TemplateData{AuthenticatedUser: id, Account: account})
if err != nil {
log.Fatal(err)
http.Error(w, "Internal Server Error", 500)
@ -234,7 +234,7 @@ func register(w http.ResponseWriter, r *http.Request) {
if len(errors) > 0 {
err := text.Execute(w, templatedata{AuthenticatedUser: authenticated_user(w, r), FormErrors: errors})
err := text.Execute(w, TemplateData{AuthenticatedUser: authenticated_user(w, r), FormErrors: errors})
if err != nil {
log.Fatal(err)
http.Error(w, "Internal Server Error", 500)
@ -277,7 +277,7 @@ func account(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case http.MethodGet:
err := text.Execute(w, templatedata{AuthenticatedUser: id, Account: account})
err := text.Execute(w, TemplateData{AuthenticatedUser: id, Account: account})
if err != nil {
log.Fatal(err)
http.Error(w, "Internal Server Error", 500)
@ -339,7 +339,7 @@ func subscribe(w http.ResponseWriter, r *http.Request) {
return
}
err = text.Execute(w, templatedata{AuthenticatedUser: id, Account: account, Prices: prices})
err = text.Execute(w, TemplateData{AuthenticatedUser: id, Account: account, Prices: prices})
if err != nil {
log.Fatal(err)
http.Error(w, "Internal Server Error", 500)
@ -369,7 +369,7 @@ func subscribe_stripe(w http.ResponseWriter, r *http.Request) {
log.Fatal(err)
}
err = text.Execute(w, templatedata{AuthenticatedUser: id, Account: account, ClientSecret: result.ClientSecret})
err = text.Execute(w, TemplateData{AuthenticatedUser: id, Account: account, ClientSecret: result.ClientSecret})
if err != nil {
log.Fatal(err)
http.Error(w, "Internal Server Error", 500)

View File

@ -16,6 +16,8 @@ body {
margin-left: auto;
margin-right: auto;
margin-bottom: 0px;
display: flex;
flex-direction: column;
min-height: 100%;
max-width: 900px;
}
@ -170,9 +172,7 @@ input {
}
footer {
position: relative;
left: 0;
bottom: 0;
margin-top: auto;
width: 100%;
background-color: #132123;
color: white;

View File

@ -1,11 +1,5 @@
<!DOCTYPE html>
<!--
/\ | |--- | | |--- || |\ /|
/__\ | |-- |---| |-- || | \ / |
/ \ |___ | | | |___ || | \/ |
-->
<html lang="en">
<head>
<title>Alfheim</title>
@ -48,7 +42,7 @@
</main>
<footer>
Alfheim &copy; 2024, Vicente Ferrari Smith, Los Andes Games, Vienna, Austria. All rights reserved.
Alfheim &copy; 2025, Vicente Ferrari Smith, Los Andes Games, Vienna, Austria. All rights reserved.
</footer>
</body>
</html>