Affiche le mot de passe admin sous la saisie en mode dev
Endpoint /api/admin/auth/hint (dev-only, 404 en prod via import.meta.dev). Le hint est aussi éliminé côté client au build grâce à import.meta.dev. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,10 @@
|
|||||||
<div v-if="loading" class="i-lucide-loader-2 h-4 w-4 animate-spin" />
|
<div v-if="loading" class="i-lucide-loader-2 h-4 w-4 animate-spin" />
|
||||||
Se connecter
|
Se connecter
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<p v-if="devHint" class="dev-hint">
|
||||||
|
Dev : <code>{{ devHint }}</code>
|
||||||
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -34,6 +38,13 @@ definePageMeta({
|
|||||||
const password = ref('')
|
const password = ref('')
|
||||||
const error = ref('')
|
const error = ref('')
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
const devHint = ref('')
|
||||||
|
|
||||||
|
if (import.meta.dev) {
|
||||||
|
$fetch('/api/admin/auth/hint').then((res: any) => {
|
||||||
|
devHint.value = res.password
|
||||||
|
}).catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
async function login() {
|
async function login() {
|
||||||
error.value = ''
|
error.value = ''
|
||||||
@@ -131,4 +142,18 @@ async function login() {
|
|||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
cursor: wait;
|
cursor: wait;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dev-hint {
|
||||||
|
margin-top: 1rem;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: hsl(20 8% 40%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dev-hint code {
|
||||||
|
color: hsl(12 76% 60%);
|
||||||
|
background: hsl(20 8% 10%);
|
||||||
|
padding: 0.125rem 0.375rem;
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
8
server/api/admin/auth/hint.get.ts
Normal file
8
server/api/admin/auth/hint.get.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export default defineEventHandler(() => {
|
||||||
|
if (!import.meta.dev) {
|
||||||
|
throw createError({ statusCode: 404, statusMessage: 'Not found' })
|
||||||
|
}
|
||||||
|
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
return { password: config.adminPassword }
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user