authorization enforced on webpages

This commit is contained in:
2025-12-30 18:08:22 -07:00
parent c01d700482
commit 240d82344c
24 changed files with 509 additions and 123 deletions
@@ -2,7 +2,19 @@
{{/* "dot" . */}}
<nav>
<nav
style="
margin: 0;
padding: 1em;
background-color: #bdf;
font-size: 1.25em;
display: flex;
flex-direction: column;
align-items: center;
"
>
<ul>
<li>
<a href="/">
@@ -10,22 +22,38 @@
</a>
</li>
{{- if .dot.UserID }}
{{/* */}}
{{- $userID := .dot.Identity.User.UserID }}
{{- $acct := .dot.Identity.Account }}
{{- $acctID := 0 }}
{{- if $acct }}
{{- $acctID = $acct.ID }}
{{- end }}
{{- if not $userID }}
<li>
<a href="/accounts/{{.dot.Account.ID}}">
<a href="/login">
Log In / Sign Up
</a>
</li>
{{- else if $acctID }}
<li>
<a href="/accounts/{{$acctID}}">
Account
</a>
</li>
<li>
<a href="/accounts/{{.dot.Account.ID}}/reports">
<a href="/accounts/{{$acctID}}/reports">
Reports
</a>
</li>
<li>
<a href="/accounts/{{.dot.Account.ID}}/inventory">
<a href="/accounts/{{$acctID}}/inventory">
Inventory
</a>
</li>
@@ -36,14 +64,6 @@
</a>
</li>
{{- else }}
<li>
<a href="/login">
Log In / Sign Up
</a>
</li>
{{- end }}
</ul>
</nav>
+20 -12
View File
@@ -38,22 +38,38 @@
</a>
</li>
{{- if .UserID }}
{{/* */}}
{{- $userID := .Identity.User.UserID }}
{{- $acct := .Identity.Account }}
{{- $acctID := 0 }}
{{- if $acct }}
{{- $acctID = $acct.ID }}
{{- end }}
{{- if not $userID }}
<li>
<a href="/accounts/{{.Account.ID}}">
<a href="/login">
Log In / Sign Up
</a>
</li>
{{- else if $acctID }}
<li>
<a href="/accounts/{{$acctID}}">
Account
</a>
</li>
<li>
<a href="/accounts/{{.Account.ID}}/reports">
<a href="/accounts/{{$acctID}}/reports">
Reports
</a>
</li>
<li>
<a href="/accounts/{{.Account.ID}}/inventory">
<a href="/accounts/{{$acctID}}/inventory">
Inventory
</a>
</li>
@@ -64,14 +80,6 @@
</a>
</li>
{{- else }}
<li>
<a href="/login">
Log In / Sign Up
</a>
</li>
{{- end }}
</ul>
</nav>
@@ -1,16 +1,20 @@
{{- .Auth.ByMatchingAccountID 2 }}
{{- define "title" }} Inventory++ Account {{ end }}
<h1>Account: {{ .Account.Email }}</h1>
{{- $acctID := .Identity.Account }}
{{- $etsyUser := .Etsy.GetUserPointerByAccountID .Account.ID }}
<h1>Account: {{ $acctID.Email }}</h1>
{{- $etsyUser := .Etsy.GetUserPointerByAccountID $acctID.ID }}
{{- if $etsyUser }}
<h3>Etsy User: {{ $etsyUser.UserID }}; Shop ID: {{ $etsyUser.ShopID }}</h3>
{{- else }}
<h3>
{{/* TODO: create this link dynamically, not EVERYTIME THE PAGE IS LOADED */}}
<a href="{{ .Etsy.GenerateConnectionURLForNewAccount .Account.ID }}">
<a href="{{ .Etsy.GenerateConnectionURLForNewAccount $acctID.ID }}">
Link Your Etsy Store!
</a>
</h3>
{{- end }}
<h2><a href="/accounts/{{.Account.ID}}/reports">View Reports</a></h2>
<h2><a href="/accounts/{{$acctID.ID}}/reports">View Reports</a></h2>
@@ -1,3 +1,5 @@
{{- .Auth.ByMatchingAccountID 2 }}
{{- define "title" }} Inventory++ {{ end }}
<h1>Inventory management page: WIP</h1>
@@ -1,3 +1,5 @@
{{- .Auth.ByMatchingAccountID 2 }}
{{- define "title" }} Inventory++ Reports {{ end }}
{{ $storeID := .Request.URL.Query.Get "store-id" }}
@@ -0,0 +1,11 @@
{{- define "title" }} Inventory++ Invalid Link {{ end }}
<section>
Invalid Link: {{ .Request.URL.Path }}
</section>
<section>
<a href="/">Return Home</a>
</section>
@@ -1,6 +1,6 @@
<h1>Home</h1>
{{- if and .UserID (not .Account.ID) }}
{{- if and .Identity.User.UserID (not .Identity.Account) }}
<h2><a href="/account-creation">New Account</a></h2>
{{- end }}
@@ -0,0 +1,11 @@
{{- define "title" }} Inventory++ Page Not Found {{ end }}
<section>
Page Not Found: {{ .Request.URL.Path }}
</section>
<section>
<a href="/">Return Home</a>
</section>