Compare commits
6 Commits
3576ccf976
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
345f3c93aa | ||
|
|
d67aa41838 | ||
|
|
6051d741b5 | ||
|
|
f591c2b0a0 | ||
|
|
5d3dcfb4bd | ||
|
|
6167df084f |
@@ -3,9 +3,7 @@
|
|||||||
"client_name": "Coffee Map",
|
"client_name": "Coffee Map",
|
||||||
"client_uri": "https://coffee.apoena.dev",
|
"client_uri": "https://coffee.apoena.dev",
|
||||||
"redirect_uris": [
|
"redirect_uris": [
|
||||||
"https://coffee.apoena.dev/oauth/callback",
|
"https://coffee.apoena.dev/oauth/callback"
|
||||||
"http://localhost:5173/oauth/callback",
|
|
||||||
"http://localhost:5174/oauth/callback"
|
|
||||||
],
|
],
|
||||||
"grant_types": ["authorization_code", "refresh_token"],
|
"grant_types": ["authorization_code", "refresh_token"],
|
||||||
"response_types": ["code"],
|
"response_types": ["code"],
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import { Agent } from '@atproto/api'
|
|||||||
// so the PDS can fetch it — even in local dev.
|
// so the PDS can fetch it — even in local dev.
|
||||||
const PROD_URL = 'https://coffee.apoena.dev'
|
const PROD_URL = 'https://coffee.apoena.dev'
|
||||||
|
|
||||||
// redirect_uri is dynamic so local dev redirects back to localhost
|
// OAuth only works on the deployed domain (web apps can't use loopback).
|
||||||
const ORIGIN = window.location.origin
|
const ORIGIN = PROD_URL
|
||||||
|
|
||||||
let _client: BrowserOAuthClient | null = null
|
let _client: BrowserOAuthClient | null = null
|
||||||
|
|
||||||
|
|||||||
@@ -40,14 +40,24 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
import { useAuthStore } from '@/stores/auth'
|
import { useAuthStore } from '@/stores/auth'
|
||||||
|
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
const handle = ref('')
|
const route = useRoute()
|
||||||
|
const handle = ref((route.query.handle as string) ?? '')
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const error = ref('')
|
const error = ref('')
|
||||||
|
|
||||||
|
const PROD_URL = 'https://coffee.apoena.dev'
|
||||||
|
const isLocalDev = window.location.origin !== PROD_URL
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
|
// OAuth state is scoped to the initiating origin — must start from production
|
||||||
|
if (isLocalDev) {
|
||||||
|
window.location.href = `${PROD_URL}/login?handle=${encodeURIComponent(handle.value.trim())}`
|
||||||
|
return
|
||||||
|
}
|
||||||
loading.value = true
|
loading.value = true
|
||||||
error.value = ''
|
error.value = ''
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="min-h-screen bg-coffee-50 flex items-center justify-center">
|
<div class="min-h-screen bg-coffee-50 flex items-center justify-center">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<div class="text-4xl mb-4">☕</div>
|
<div class="text-4xl mb-4">☕</div>
|
||||||
<p v-if="error" class="text-red-600">{{ error }}</p>
|
<p v-if="error || auth.error" class="text-red-600 max-w-sm px-4">{{ error || auth.error }}</p>
|
||||||
<p v-else class="text-coffee-600">Signing you in…</p>
|
<p v-else class="text-coffee-600">Signing you in…</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -26,7 +26,7 @@ onMounted(async () => {
|
|||||||
await shops.fetchAll()
|
await shops.fetchAll()
|
||||||
router.replace('/')
|
router.replace('/')
|
||||||
} else {
|
} else {
|
||||||
error.value = 'Authentication failed. Please try again.'
|
error.value = auth.error ?? 'Authentication failed — check console for details.'
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error.value = e instanceof Error ? e.message : 'Authentication error'
|
error.value = e instanceof Error ? e.message : 'Authentication error'
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import UnoCSS from 'unocss/vite'
|
|||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
server: {
|
||||||
|
host: '127.0.0.1',
|
||||||
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||||
|
|||||||
Reference in New Issue
Block a user