✨ Enhance OAuth callback to support multiple providers and improve UI/UX styling
This commit is contained in:
@@ -5,25 +5,25 @@
|
|||||||
<div v-if="loading" class="loading-state">
|
<div v-if="loading" class="loading-state">
|
||||||
<div class="spinner"></div>
|
<div class="spinner"></div>
|
||||||
<h2>Authenticating...</h2>
|
<h2>Authenticating...</h2>
|
||||||
<p>Please wait while we complete your OAuth login</p>
|
<p>Please wait while we complete your {{ provider }} OAuth login</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="error" class="error-state">
|
<div v-else-if="error" class="error-state">
|
||||||
<div class="error-icon">✕</div>
|
<div class="error-icon">✕</div>
|
||||||
<h2>Authentication Failed</h2>
|
<h2>Authentication Failed</h2>
|
||||||
<p class="error-message">{{ error }}</p>
|
<p class="error-message">{{ error }}</p>
|
||||||
<router-link to="/challonge-test" class="btn btn-primary">
|
<router-link to="/auth" class="btn btn-primary">
|
||||||
Back to Challonge Test
|
Back to Authentication Settings
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="success" class="success-state">
|
<div v-else-if="success" class="success-state">
|
||||||
<div class="success-icon">✓</div>
|
<div class="success-icon">✓</div>
|
||||||
<h2>Authentication Successful!</h2>
|
<h2>{{ provider }} Authentication Successful!</h2>
|
||||||
<p>You're now logged in with OAuth</p>
|
<p>You're now authenticated with {{ provider }}</p>
|
||||||
<p class="redirect-info">Redirecting in {{ countdown }} seconds...</p>
|
<p class="redirect-info">Redirecting in {{ countdown }} seconds...</p>
|
||||||
<router-link to="/challonge-test" class="btn btn-primary">
|
<router-link :to="returnTo || '/auth'" class="btn btn-primary">
|
||||||
Continue to Challonge Test
|
Continue to Authentication Settings
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -34,28 +34,36 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { useChallongeOAuth } from '../composables/useChallongeOAuth.js';
|
import { useOAuth } from '../composables/useOAuth.js';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { exchangeCode } = useChallongeOAuth();
|
|
||||||
|
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const error = ref(null);
|
const error = ref(null);
|
||||||
const success = ref(false);
|
const success = ref(false);
|
||||||
const countdown = ref(3);
|
const countdown = ref(3);
|
||||||
|
const provider = ref('challonge');
|
||||||
|
const returnTo = ref(null);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// Get authorization code and state from URL
|
// Get provider from query or sessionStorage (default: 'challonge' for backwards compatibility)
|
||||||
|
provider.value = route.query.provider || sessionStorage.getItem('oauth_provider') || 'challonge';
|
||||||
|
|
||||||
|
// Get redirect destination (default: /auth)
|
||||||
|
returnTo.value = route.query.return_to || sessionStorage.getItem('oauth_return_to') || '/auth';
|
||||||
|
|
||||||
|
// Get OAuth parameters from URL
|
||||||
const code = route.query.code;
|
const code = route.query.code;
|
||||||
const state = route.query.state;
|
const state = route.query.state;
|
||||||
const errorParam = route.query.error;
|
const errorParam = route.query.error;
|
||||||
const errorDescription = route.query.error_description;
|
const errorDescription = route.query.error_description;
|
||||||
|
|
||||||
// Handle OAuth errors
|
// Handle OAuth errors from provider
|
||||||
if (errorParam) {
|
if (errorParam) {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
error.value = errorDescription || `OAuth error: ${errorParam}`;
|
error.value = errorDescription || `OAuth error: ${errorParam}`;
|
||||||
|
console.warn(`OAuth error from ${provider.value}:`, errorParam);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +75,9 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Exchange authorization code for tokens
|
// Exchange code for tokens using unified OAuth handler
|
||||||
await exchangeCode(code, state);
|
const oauth = useOAuth(provider.value);
|
||||||
|
await oauth.exchangeCode(code, state);
|
||||||
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
success.value = true;
|
success.value = true;
|
||||||
@@ -78,7 +87,7 @@ onMounted(async () => {
|
|||||||
countdown.value--;
|
countdown.value--;
|
||||||
if (countdown.value <= 0) {
|
if (countdown.value <= 0) {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
router.push('/challonge-test');
|
router.push(returnTo.value);
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -100,148 +109,97 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
max-width: 500px;
|
max-width: 400px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.callback-card {
|
.callback-card {
|
||||||
background: white;
|
background: white;
|
||||||
border-radius: 12px;
|
border-radius: 8px;
|
||||||
padding: 3rem;
|
padding: 2rem;
|
||||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-state,
|
||||||
|
.error-state,
|
||||||
|
.success-state {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loading State */
|
|
||||||
.loading-state {
|
|
||||||
padding: 2rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spinner {
|
.spinner {
|
||||||
width: 64px;
|
width: 48px;
|
||||||
height: 64px;
|
height: 48px;
|
||||||
border: 5px solid #f3f3f3;
|
border: 4px solid #667eea;
|
||||||
border-top: 5px solid #667eea;
|
border-top-color: transparent;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin: 0 auto 2rem;
|
animation: spin 0.8s linear infinite;
|
||||||
animation: spin 1s linear infinite;
|
margin: 0 auto 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes spin {
|
@keyframes spin {
|
||||||
0% {
|
to {
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Success State */
|
.error-icon {
|
||||||
.success-state {
|
font-size: 3rem;
|
||||||
padding: 2rem 0;
|
color: #dc3545;
|
||||||
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.success-icon {
|
.success-icon {
|
||||||
width: 80px;
|
|
||||||
height: 80px;
|
|
||||||
background: #10b981;
|
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
margin: 0 auto 1.5rem;
|
|
||||||
font-size: 3rem;
|
font-size: 3rem;
|
||||||
color: white;
|
color: #28a745;
|
||||||
animation: scaleIn 0.5s ease;
|
margin-bottom: 1rem;
|
||||||
}
|
|
||||||
|
|
||||||
/* Error State */
|
|
||||||
.error-state {
|
|
||||||
padding: 2rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.error-icon {
|
|
||||||
width: 80px;
|
|
||||||
height: 80px;
|
|
||||||
background: #ef4444;
|
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
margin: 0 auto 1.5rem;
|
|
||||||
font-size: 3rem;
|
|
||||||
color: white;
|
|
||||||
animation: scaleIn 0.5s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes scaleIn {
|
|
||||||
0% {
|
|
||||||
transform: scale(0);
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
50% {
|
|
||||||
transform: scale(1.1);
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
transform: scale(1);
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
font-size: 2rem;
|
margin: 1rem 0;
|
||||||
font-weight: 700;
|
font-size: 1.5rem;
|
||||||
margin-bottom: 1rem;
|
color: #333;
|
||||||
color: #1f2937;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
font-size: 1.1rem;
|
color: #666;
|
||||||
color: #6b7280;
|
margin: 0.5rem 0;
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.error-message {
|
.error-message {
|
||||||
color: #ef4444;
|
background: #fff3cd;
|
||||||
font-weight: 500;
|
border: 1px solid #ffc107;
|
||||||
|
border-radius: 4px;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
background: #fee2e2;
|
margin: 1rem 0;
|
||||||
border-radius: 8px;
|
color: #856404;
|
||||||
margin: 1.5rem 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.redirect-info {
|
.redirect-info {
|
||||||
font-size: 0.95rem;
|
font-size: 0.9rem;
|
||||||
color: #9ca3af;
|
font-weight: 500;
|
||||||
margin-top: 1rem;
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 0.75rem 2rem;
|
|
||||||
background: #667eea;
|
|
||||||
color: white;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-weight: 600;
|
|
||||||
margin-top: 1.5rem;
|
margin-top: 1.5rem;
|
||||||
transition: all 0.3s ease;
|
padding: 0.75rem 1.5rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
text-decoration: none;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: all 0.2s;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:hover {
|
|
||||||
background: #5568d3;
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary {
|
.btn-primary {
|
||||||
background: #667eea;
|
background: #667eea;
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary:hover {
|
.btn-primary:hover {
|
||||||
background: #5568d3;
|
background: #5568d3;
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user