userhandling #16

Merged
kalipso merged 10 commits from userhandling into master 2025-04-15 01:06:12 +02:00
4 changed files with 11 additions and 6 deletions
Showing only changes of commit 1525f44687 - Show all commits

View File

@@ -141,10 +141,12 @@ func (rc *UserController) LoginHandler(c *gin.Context) {
}
func CreateSessionData(c *gin.Context, extra any) gin.H {
_, exists := c.Get("user")
user, exists := c.Get("user")
userImpl, _ := user.(models.User)
return gin.H{
"loggedIn": exists,
"isAdmin": userImpl.IsAdmin,
"data": extra,
}
}

View File

@@ -5,7 +5,7 @@
<h3 class="text-lg">{{ .data.shopItem.Name }}</h3>
<i class="text-xs">{{ .data.shopItem.Description }}</i>
<p class="">Price: {{ .data.shopItem.BasePrice }}</p>
{{ if .loggedIn }}
{{ if .isAdmin }}
<p class="mt-10 text-center text-sm/6 text-red-500">
Do you really want to delete this item??

View File

@@ -25,7 +25,7 @@
{{ end }}
-->
</div>
{{ if .loggedIn }}
{{ if .isAdmin }}
<div class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0 px-4 sm:px-8">
<a href="/additem" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Add Item</a>
<a href="/batchupload" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300

View File

@@ -9,15 +9,18 @@
<img class="w-full h-full object-cover" src="/{{ .data.shopItem.Image}}" alt="Product Image">
</div>
<div class="flex -mx-2 mb-4">
<div class="w-1/3 px-2">
<button type="button" class="w-full bg-blue-900 dark:bg-gray-600 text-white py-2 px-4 rounded-lg font-bold hover:bg-gray-800 dark:hover:bg-gray-700"><a href="/{{ .data.shopItem.Pdf }}">View</a></button>
</div>
{{ if .loggedIn }}
<input type="hidden" id="{{ .data.shopItem.ID}}" name="ShopItemId" value="{{ .data.shopItem.ID }}">
<div class="w-1/3 px-2">
<button type="submit" class="w-full bg-gray-900 dark:bg-gray-600 text-white py-2 px-4 rounded-lg font-bold hover:bg-gray-800 dark:hover:bg-gray-700">Add to Cart</button>
</div>
{{ end }}
<div class="w-1/3 px-2">
<button type="button" class="w-full bg-blue-900 dark:bg-gray-600 text-white py-2 px-4 rounded-lg font-bold hover:bg-gray-800 dark:hover:bg-gray-700"><a href="/{{ .data.shopItem.Pdf }}">View</a></button>
</div>
{{ if .isAdmin }}
<div class="w-1/3 px-2">
<button type="button" class="w-full bg-blue-900 dark:bg-gray-600 text-white py-2 px-4 rounded-lg font-bold hover:bg-gray-800 dark:hover:bg-gray-700"><a href="{{ .data.shopItem.ID }}/edit">Edit</a></button>
</div>