2 Commits

Author SHA1 Message Date
a70c762f10 fix oauth page url 2025-06-19 12:59:16 +09:00
845e7b0cbd fix oauth package name 2025-06-19 12:59:16 +09:00
5 changed files with 22 additions and 20 deletions

Binary file not shown.

View File

@@ -133,6 +133,7 @@ export default function App() {
<CommentForm <CommentForm
user={user} user={user}
agent={agent} agent={agent}
pageContext={pageContext}
onCommentPosted={() => { onCommentPosted={() => {
refreshAdminData?.() refreshAdminData?.()
refreshUserData?.() refreshUserData?.()

View File

@@ -2,21 +2,22 @@ import React, { useState } from 'react'
import { atproto, collections } from '../api/atproto.js' import { atproto, collections } from '../api/atproto.js'
import { env } from '../config/env.js' import { env } from '../config/env.js'
export default function CommentForm({ user, agent, onCommentPosted }) { export default function CommentForm({ user, agent, onCommentPosted, pageContext }) {
const [text, setText] = useState('') const [text, setText] = useState('')
const [url, setUrl] = useState('')
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [error, setError] = useState(null) const [error, setError] = useState(null)
// Get current URL automatically
const currentUrl = pageContext?.url || window.location.href
const handleSubmit = async (e) => { const handleSubmit = async (e) => {
e.preventDefault() e.preventDefault()
if (!text.trim() || !url.trim()) return if (!text.trim()) return
setLoading(true) setLoading(true)
setError(null) setError(null)
try { try {
const currentUrl = url.trim()
const timestamp = new Date().toISOString() const timestamp = new Date().toISOString()
// Create ai.syui.log record structure (new unified format) // Create ai.syui.log record structure (new unified format)
@@ -55,7 +56,6 @@ export default function CommentForm({ user, agent, onCommentPosted }) {
// Clear form // Clear form
setText('') setText('')
setUrl('')
// Notify parent component // Notify parent component
if (onCommentPosted) { if (onCommentPosted) {
@@ -86,18 +86,8 @@ export default function CommentForm({ user, agent, onCommentPosted }) {
<h3>コメントを投稿</h3> <h3>コメントを投稿</h3>
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<div className="form-group"> <div className="form-group" style={{ marginBottom: '8px', fontSize: '0.9em', color: 'var(--text-secondary)' }}>
<label htmlFor="comment-url">ページURL:</label> <span>ページ: {currentUrl}</span>
<input
id="comment-url"
type="url"
value={url}
onChange={(e) => setUrl(e.target.value)}
placeholder="https://syui.ai/posts/example"
required
disabled={loading}
className="form-input"
/>
</div> </div>
<div className="form-group"> <div className="form-group">

View File

@@ -20,11 +20,15 @@ export default function OAuthCallback({ onAuthSuccess }) {
} }
if (code) { if (code) {
setStatus('認証成功!メインページに戻ります...') setStatus('認証成功!元のページに戻ります...')
// 少し待ってからメインページにリダイレクト // 認証前のページを復元するか、ルートページに戻る
const returnUrl = sessionStorage.getItem('oauth_return_url') || '/'
sessionStorage.removeItem('oauth_return_url')
// 少し待ってから元のページにリダイレクト
setTimeout(() => { setTimeout(() => {
window.location.href = '/' window.location.href = returnUrl
}, 1500) }, 1500)
} else { } else {
setStatus('認証情報が見つかりません') setStatus('認証情報が見つかりません')

View File

@@ -97,6 +97,13 @@ export class OAuthService {
async login(handle) { async login(handle) {
await this.initialize() await this.initialize()
// Save current URL for return after OAuth
const currentUrl = window.location.href
// Only save if not already on oauth callback page
if (!currentUrl.includes('/oauth/callback')) {
sessionStorage.setItem('oauth_return_url', currentUrl)
}
const client = isSyuIsHandle(handle) ? this.clients.syu : this.clients.bsky const client = isSyuIsHandle(handle) ? this.clients.syu : this.clients.bsky
const authUrl = await client.authorize(handle, { const authUrl = await client.authorize(handle, {
scope: 'atproto transition:generic' scope: 'atproto transition:generic'