auth: split dev-mode auth constructor and wire up dev-login/logout UI
Squeamish about New()'s empty-domain-string sentinel for "dev mode, skip OIDC discovery" - split into New (always makes a real OIDC discovery call, all params required) and NewDev (no ctx/domain/credentials at all, since none are used). main.go now branches on cfg.DevAuthEnabled to pick the right constructor instead of main.go/config.go coordinating on when it's safe to pass empty strings. Also finishes out the dev-auth flow this enables: config.Load reads a DEV_AUTH_ENABLED-aware env file and only requires Auth0 vars when dev auth is off; a PORT config var replaces the hardcoded :8082; and the nav UI (layout/index templates, ui router) points login/logout links at /api/auth/dev-login and a new /api/auth/dev-logout route when dev auth is enabled, so the whole login/logout loop works locally without a real Auth0 app. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+25
-11
@@ -5,6 +5,7 @@
|
||||
{{- $acctID = .Identity.Account.AccountID }}
|
||||
{{- end }}
|
||||
{{- $mockMode := .MockMode }}
|
||||
{{- $devAuthEnabled := .DevAuthEnabled }}
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -117,8 +118,13 @@
|
||||
>
|
||||
{{- if not $loggedIn }}
|
||||
|
||||
{{- $loginPath := "/api/auth/login" }}
|
||||
{{- if $devAuthEnabled }}
|
||||
{{- $loginPath = "/api/auth/dev-login" }}
|
||||
{{- end }}
|
||||
|
||||
{{ template "navbar-link" (props
|
||||
"Href" "/api/auth/login"
|
||||
"Href" $loginPath
|
||||
"NoHXBoost" true
|
||||
"Selected" (eq $path "/auth/login")
|
||||
"Content" "Log In"
|
||||
@@ -231,7 +237,8 @@
|
||||
<a href="mailto:contact-us@inventory-plus-plus.com" class="p-[1em] font-display text-center">Contact Us</a>
|
||||
<a href="mailto:support@inventory-plus-plus.com" class="p-[1em] font-display text-center">Support</a>
|
||||
</address>
|
||||
{{- if .Identity.Claims.Picture }}
|
||||
|
||||
{{- if (or .Identity.Claims.Picture .Identity.Claims.Name) }}
|
||||
<button
|
||||
popovertarget="identity-popover"
|
||||
class="
|
||||
@@ -244,14 +251,21 @@
|
||||
items-center
|
||||
"
|
||||
>
|
||||
<img
|
||||
src="{{ .Identity.Claims.Picture }}"
|
||||
class="rounded-[50%]"
|
||||
style="
|
||||
max-height: 3rem;
|
||||
margin: 1rem 0;
|
||||
"
|
||||
/>
|
||||
{{ if .Identity.Claims.Picture }}
|
||||
<img
|
||||
src="{{ .Identity.Claims.Picture }}"
|
||||
class="rounded-[50%]"
|
||||
style="
|
||||
max-height: 3rem;
|
||||
margin: 1rem 0;
|
||||
"
|
||||
/>
|
||||
{{ else if .Identity.Claims.Name }}
|
||||
{{ .Identity.Claims.Name }}
|
||||
{{ else }}
|
||||
User
|
||||
{{ end }}
|
||||
|
||||
</button>
|
||||
<div
|
||||
popover="auto"
|
||||
@@ -308,7 +322,7 @@
|
||||
</div>
|
||||
|
||||
<a
|
||||
href="/api/auth/logout"
|
||||
href="/api/auth/{{if $devAuthEnabled}}dev-logout{{else}}logout{{end}}"
|
||||
hx-boost="false"
|
||||
class="
|
||||
w-fit
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{{- $loggedIn := and (and .Identity .Identity.AccessToken) true -}}
|
||||
{{- $devAuthEnabled := .DevAuthEnabled }}
|
||||
|
||||
|
||||
<section class="flex justify-center max-w-full mt-[3em] mb-[3em]">
|
||||
@@ -26,7 +27,7 @@
|
||||
Create an Account
|
||||
</a>
|
||||
{{- else }}
|
||||
<a href="/api/auth/login" hx-boost="false" class="block p-[1em] font-bold">
|
||||
<a href="/api/auth/{{if $devAuthEnabled}}dev-login{{else}}login{{end}}" hx-boost="false" class="block p-[1em] font-bold">
|
||||
New Login
|
||||
</a>
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user