feat(settings): link the Steam account through Steam
Build, Test & Push Frontend / quality-check (push) Successful in 16s
Build, Test & Push Frontend / docker (push) Successful in 25s

A Steam card in the settings links, verifies or unlinks the Steam
account through "Sign in through Steam". After the way back the page
shows the outcome and refreshes the session, so Core gets the new
Steam ID at once. Registration and settings no longer ask for a typed
Steam ID.
This commit is contained in:
lobo committed 2026-09-26 11:20:04 +02:00
1 parent 23ab5a91e7
commit ca75e6a530
13 files changed
+393 -86

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import {apiFetch} from './api.js';
// Only Steam's own login page; a URL from an API must not send the user anywhere else.
export const STEAM_LOGIN_PREFIX = 'https://steamcommunity.com/openid/login?';
/**
* POST /api/users/steam-link, then leaves the page for Steam's login. The caller handles a response that is not ok.
*
* @returns the response; when it is ok the browser is already on its way to Steam
*/
export async function startSteamLink() {
const response = await apiFetch(`${import.meta.env.VITE_API_URL}/api/users/steam-link`, {method: 'POST'});
if (!response.ok) return response;
const {redirectUrl} = await response.json();
if (typeof redirectUrl !== 'string' || !redirectUrl.startsWith(STEAM_LOGIN_PREFIX)) {
throw new Error('Auth sent no Steam login URL');
}
window.location.assign(redirectUrl);
return response;
}
/**
* DELETE /api/users/steam-link. Auth sets a new access cookie without the Steam ID.
*/
export const unlinkSteam = () =>
apiFetch(`${import.meta.env.VITE_API_URL}/api/users/steam-link`, {method: 'DELETE'});