git-svn-id: svn://losandesgames.com/alfheim-website@8 15359d88-9307-4e75-a9c1-e5686e5897df
This commit is contained in:
Vicente Ferrari Smith 2024-05-16 16:54:47 +00:00
parent c32d594d65
commit 537455a5d4
2 changed files with 11 additions and 3 deletions

View File

@ -48,7 +48,10 @@ func home(w http.ResponseWriter, r *http.Request) {
return return
} }
text, err := template.ParseFiles("ui/base.html", "ui/index.html") id := authenticated_user(r)
account, err := users.Get_account(id)
text, err := template.ParseFiles("base.html", "index.html")
if err != nil { if err != nil {
http.Error(w, "Internal Server Error", 500) http.Error(w, "Internal Server Error", 500)
log.Fatal(err) log.Fatal(err)
@ -57,7 +60,7 @@ func home(w http.ResponseWriter, r *http.Request) {
switch r.Method { switch r.Method {
case http.MethodGet: case http.MethodGet:
err = text.Execute(w, templatedata{}) err = text.Execute(w, templatedata{AuthenticatedUser: id, Account: account})
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
http.Error(w, "Internal Server Error", 500) http.Error(w, "Internal Server Error", 500)
@ -132,10 +135,13 @@ func logout(w http.ResponseWriter, r *http.Request) {
log.Fatal(err) log.Fatal(err)
} }
id := authenticated_user(r)
account, err := users.Get_account(id)
switch r.Method { switch r.Method {
case http.MethodGet: case http.MethodGet:
text.Execute(w, templatedata{}) text.Execute(w, templatedata{AuthenticatedUser: id, Account: account})
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
http.Error(w, "Internal Server Error", 500) http.Error(w, "Internal Server Error", 500)

View File

@ -51,6 +51,8 @@ func main() {
flag.Parse() flag.Parse()
fmt.Println("Hello, Sailor!") fmt.Println("Hello, Sailor!")
store.MaxAge(0)
var err error var err error
db, err := sql.Open("postgres", "postgres://elves_database:iK2SoVbDhdCki5n3LxGyP6zKpLspt4@80.240.25.87/elves_database") db, err := sql.Open("postgres", "postgres://elves_database:iK2SoVbDhdCki5n3LxGyP6zKpLspt4@80.240.25.87/elves_database")
if err != nil { if err != nil {