space-game/src/components/auth/UserProfile.svelte
Michael Mainguy fe88c2bf47 Add My Levels tab, profile page, and token auth system
- Add My Levels tab to website level selection for viewing private levels
- Add profile page for generating/managing editor plugin tokens
- Create user_tokens table and RPC functions for token-based auth
- Fix cloudLevelService to use maybeSingle() for admin and level queries
- Fix getLevelById to try authenticated client first for private levels
- Add rotation support to asteroids, base, sun, and planets
- Remove deprecated difficultyConfig from level files
- Add editor script components for BabylonJS Editor integration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-09 07:06:40 -06:00

55 lines
1.3 KiB
Svelte

<script lang="ts">
import { Link } from 'svelte-routing';
import { authStore } from '../../stores/auth';
import Button from '../shared/Button.svelte';
async function handleLogin() {
await authStore.login();
}
async function handleLogout() {
await authStore.logout();
}
</script>
<div id="userProfile">
{#if $authStore.isLoading}
<span class="loading">Loading...</span>
{:else if $authStore.isAuthenticated && $authStore.user}
<div class="user-info">
<Link to="/profile" class="user-name-link">{$authStore.user.name || $authStore.user.email}</Link>
<Button variant="secondary" on:click={handleLogout}>Logout</Button>
</div>
{:else}
<Button variant="primary" on:click={handleLogin}>Sign In</Button>
{/if}
</div>
<style>
#userProfile {
display: flex;
align-items: center;
gap: var(--space-sm, 0.5rem);
}
.user-info {
display: flex;
align-items: center;
gap: var(--space-sm, 0.5rem);
}
:global(.user-name-link) {
color: var(--color-text, #fff);
font-size: var(--font-size-sm, 0.875rem);
text-decoration: none;
}
:global(.user-name-link:hover) {
color: var(--color-primary, #4fc3f7);
}
.loading {
color: var(--color-text-secondary, #ccc);
font-size: var(--font-size-sm, 0.875rem);
}
</style>