fix: support VK ID OAuth 2.1 device_id in frontend

- Extract device_id from VK callback URL query params
- Pass device_id through store → API → backend
- Add useRef guard to prevent useEffect double-fire
- Fix URL validation catch-block anti-pattern in Login
- Improve error extraction in OAuthCallback (show Error.message)
This commit is contained in:
Fringg
2026-03-02 04:10:05 +03:00
parent 3f050396b8
commit 60f16e64e8
4 changed files with 28 additions and 13 deletions

View File

@@ -127,14 +127,15 @@ export default function Login() {
const { authorize_url, state } = await authApi.getOAuthAuthorizeUrl(provider);
// Validate redirect URL — only allow HTTPS to prevent open redirect
let parsed: URL;
try {
const parsed = new URL(authorize_url);
if (parsed.protocol !== 'https:') {
throw new Error('Invalid OAuth redirect URL');
}
parsed = new URL(authorize_url);
} catch {
throw new Error('Invalid OAuth redirect URL');
}
if (parsed.protocol !== 'https:') {
throw new Error('Invalid OAuth redirect URL');
}
saveOAuthState(state, provider);
window.location.href = authorize_url;