Fix login: show link instead of popup, add code paste UI
This commit is contained in:
parent
28a9d97d7a
commit
0d0b4019dc
1 changed files with 15 additions and 10 deletions
|
|
@ -90,11 +90,11 @@ const App = () => {
|
||||||
const response = await fetch('/api/auth/login', { method: 'POST' });
|
const response = await fetch('/api/auth/login', { method: 'POST' });
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setAuthStatus(prev => ({ ...prev, ...data }));
|
setAuthStatus(prev => ({ ...prev, ...data }));
|
||||||
if (data.auth_url) {
|
if (data.status === 'error') {
|
||||||
window.open(data.auth_url, '_blank');
|
|
||||||
} else if (data.status === 'error') {
|
|
||||||
alert(data.message || 'Login failed. Check container logs.');
|
alert(data.message || 'Login failed. Check container logs.');
|
||||||
}
|
}
|
||||||
|
// Don't try window.open — popup blockers kill it.
|
||||||
|
// The auth_url will be shown as a clickable link in the pending state.
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error initiating login:', error);
|
console.error('Error initiating login:', error);
|
||||||
alert('Failed to connect to auth endpoint');
|
alert('Failed to connect to auth endpoint');
|
||||||
|
|
@ -255,13 +255,18 @@ const App = () => {
|
||||||
{authStatus?.status === 'logged_in' ? (
|
{authStatus?.status === 'logged_in' ? (
|
||||||
<span className="auth-ok" title={authStatus.account}>● {authStatus.account || 'Logged in'}</span>
|
<span className="auth-ok" title={authStatus.account}>● {authStatus.account || 'Logged in'}</span>
|
||||||
) : authStatus?.status === 'pending' ? (
|
) : authStatus?.status === 'pending' ? (
|
||||||
<form className="header-code-form" onSubmit={handleSubmitCode}>
|
<div className="header-auth-pending">
|
||||||
<input type="text" placeholder="Paste auth code here" value={authCode}
|
{authStatus.auth_url && (
|
||||||
onChange={e => setAuthCode(e.target.value)} className="header-code-input" />
|
<a href={authStatus.auth_url} target="_blank" rel="noreferrer" className="header-auth-link">1. Open login →</a>
|
||||||
<button type="submit" className="header-code-btn" disabled={codeSubmitting}>
|
)}
|
||||||
{codeSubmitting ? '…' : '→'}
|
<form className="header-code-form" onSubmit={handleSubmitCode}>
|
||||||
</button>
|
<input type="text" placeholder="2. Paste code" value={authCode}
|
||||||
</form>
|
onChange={e => setAuthCode(e.target.value)} className="header-code-input" />
|
||||||
|
<button type="submit" className="header-code-btn" disabled={codeSubmitting}>
|
||||||
|
{codeSubmitting ? '…' : '→'}
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<button className="auth-login-btn" onClick={handleLogin} disabled={loginLoading}>
|
<button className="auth-login-btn" onClick={handleLogin} disabled={loginLoading}>
|
||||||
{loginLoading ? '⏳ Connecting…' : '🔐 Login with Claude Max'}
|
{loginLoading ? '⏳ Connecting…' : '🔐 Login with Claude Max'}
|
||||||
|
|
|
||||||
Reference in a new issue