mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
Refactor OAuth login URLs and improve deep link handling.
Updated OAuth provider login URLs to use "responseType=json" for development mode. Enhanced deep link handling by adding support for an additional "key" parameter to distinguish token types.
This commit is contained in:
+1
-1
Submodule skills updated: 88c9c8c8d1...e6dd1730eb
@@ -52,7 +52,7 @@ export const oauthProviderConfigs: OAuthProviderConfig[] = [
|
||||
color: 'bg-white border border-gray-200',
|
||||
hoverColor: 'hover:bg-gray-50 hover:border-gray-300',
|
||||
textColor: 'text-gray-900',
|
||||
loginUrl: `${BACKEND_URL}/auth/google/login${IS_DEV ? '?debug=true' : ''}`,
|
||||
loginUrl: `${BACKEND_URL}/auth/google/login?${IS_DEV ? 'responseType=json' : ''}`,
|
||||
},
|
||||
{
|
||||
id: 'github',
|
||||
@@ -61,7 +61,7 @@ export const oauthProviderConfigs: OAuthProviderConfig[] = [
|
||||
color: 'bg-gray-900 border border-gray-800',
|
||||
hoverColor: 'hover:bg-gray-800 hover:border-gray-700',
|
||||
textColor: 'text-white',
|
||||
loginUrl: `${BACKEND_URL}/auth/github/login${IS_DEV ? '?debug=true' : ''}`,
|
||||
loginUrl: `${BACKEND_URL}/auth/github/login?${IS_DEV ? 'responseType=json' : ''}`,
|
||||
},
|
||||
{
|
||||
id: 'twitter',
|
||||
@@ -70,7 +70,7 @@ export const oauthProviderConfigs: OAuthProviderConfig[] = [
|
||||
color: 'bg-black border border-gray-800',
|
||||
hoverColor: 'hover:bg-gray-900 hover:border-gray-700',
|
||||
textColor: 'text-white',
|
||||
loginUrl: `${BACKEND_URL}/auth/twitter/login${IS_DEV ? '?debug=true' : ''}`,
|
||||
loginUrl: `${BACKEND_URL}/auth/twitter/login?${IS_DEV ? 'responseType=json' : ''}`,
|
||||
},
|
||||
{
|
||||
id: 'discord',
|
||||
@@ -79,7 +79,7 @@ export const oauthProviderConfigs: OAuthProviderConfig[] = [
|
||||
color: 'bg-indigo-600 border border-indigo-500',
|
||||
hoverColor: 'hover:bg-indigo-700 hover:border-indigo-600',
|
||||
textColor: 'text-white',
|
||||
loginUrl: `${BACKEND_URL}/auth/discord/login${IS_DEV ? '?debug=true' : ''}`,
|
||||
loginUrl: `${BACKEND_URL}/auth/discord/login?${IS_DEV ? 'responseType=json' : ''}`,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import { isTauri as coreIsTauri, invoke } from '@tauri-apps/api/core';
|
||||
import { getCurrent, onOpenUrl } from '@tauri-apps/plugin-deep-link';
|
||||
import {invoke, isTauri as coreIsTauri} from '@tauri-apps/api/core';
|
||||
import {getCurrent, onOpenUrl} from '@tauri-apps/plugin-deep-link';
|
||||
|
||||
import { skillManager } from '../lib/skills/manager';
|
||||
import { consumeLoginToken, fetchIntegrationTokens } from '../services/api/authApi';
|
||||
import { buildManualSentryEvent, enqueueError } from '../services/errorReportQueue';
|
||||
import { store } from '../store';
|
||||
import { setToken } from '../store/authSlice';
|
||||
import { setSkillState } from '../store/skillsSlice';
|
||||
import {
|
||||
decryptIntegrationTokens,
|
||||
hexToBase64,
|
||||
type IntegrationTokensPayload,
|
||||
} from './integrationTokensCrypto';
|
||||
import {skillManager} from '../lib/skills/manager';
|
||||
import {consumeLoginToken, fetchIntegrationTokens} from '../services/api/authApi';
|
||||
import {buildManualSentryEvent, enqueueError} from '../services/errorReportQueue';
|
||||
import {store} from '../store';
|
||||
import {setToken} from '../store/authSlice';
|
||||
import {setSkillState} from '../store/skillsSlice';
|
||||
import {decryptIntegrationTokens, hexToBase64, type IntegrationTokensPayload,} from './integrationTokensCrypto';
|
||||
|
||||
function getCurrentUserId(): string | null {
|
||||
const state = store.getState();
|
||||
@@ -40,11 +36,13 @@ function getCurrentUserId(): string | null {
|
||||
*/
|
||||
const handleAuthDeepLink = async (parsed: URL) => {
|
||||
const token = parsed.searchParams.get('token');
|
||||
const key = parsed.searchParams.get('key');
|
||||
if (!token) {
|
||||
console.warn('[DeepLink] URL did not contain a token query parameter');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log('[DeepLink] Received auth token');
|
||||
|
||||
try {
|
||||
@@ -53,9 +51,16 @@ const handleAuthDeepLink = async (parsed: URL) => {
|
||||
console.warn('[DeepLink] Failed to show window:', err);
|
||||
}
|
||||
|
||||
const jwtToken = await consumeLoginToken(token);
|
||||
store.dispatch(setToken(jwtToken));
|
||||
window.location.hash = '/onboarding';
|
||||
if (key === 'auth') {
|
||||
store.dispatch(setToken(token));
|
||||
window.location.hash = '/onboarding';
|
||||
} else {
|
||||
const jwtToken = await consumeLoginToken(token);
|
||||
store.dispatch(setToken(jwtToken));
|
||||
window.location.hash = '/onboarding';
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user