mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-09-13 14:22:25 +03:00
Support oidc action param for login and register page (#2389)
This commit is contained in:
parent
50cc78788f
commit
acc7d4ff56
3 changed files with 9 additions and 3 deletions
|
@ -1,19 +1,21 @@
|
||||||
import { Avatar, AvatarImage, Box, Button, Text } from 'folds';
|
import { Avatar, AvatarImage, Box, Button, Text } from 'folds';
|
||||||
import { IIdentityProvider, createClient } from 'matrix-js-sdk';
|
import { IIdentityProvider, SSOAction, createClient } from 'matrix-js-sdk';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { useAutoDiscoveryInfo } from '../../hooks/useAutoDiscoveryInfo';
|
import { useAutoDiscoveryInfo } from '../../hooks/useAutoDiscoveryInfo';
|
||||||
|
|
||||||
type SSOLoginProps = {
|
type SSOLoginProps = {
|
||||||
providers?: IIdentityProvider[];
|
providers?: IIdentityProvider[];
|
||||||
redirectUrl: string;
|
redirectUrl: string;
|
||||||
|
action?: SSOAction;
|
||||||
saveScreenSpace?: boolean;
|
saveScreenSpace?: boolean;
|
||||||
};
|
};
|
||||||
export function SSOLogin({ providers, redirectUrl, saveScreenSpace }: SSOLoginProps) {
|
export function SSOLogin({ providers, redirectUrl, action, saveScreenSpace }: SSOLoginProps) {
|
||||||
const discovery = useAutoDiscoveryInfo();
|
const discovery = useAutoDiscoveryInfo();
|
||||||
const baseUrl = discovery['m.homeserver'].base_url;
|
const baseUrl = discovery['m.homeserver'].base_url;
|
||||||
const mx = useMemo(() => createClient({ baseUrl }), [baseUrl]);
|
const mx = useMemo(() => createClient({ baseUrl }), [baseUrl]);
|
||||||
|
|
||||||
const getSSOIdUrl = (ssoId?: string): string => mx.getSsoLoginUrl(redirectUrl, 'sso', ssoId);
|
const getSSOIdUrl = (ssoId?: string): string =>
|
||||||
|
mx.getSsoLoginUrl(redirectUrl, 'sso', ssoId, action);
|
||||||
|
|
||||||
const withoutIcon = providers
|
const withoutIcon = providers
|
||||||
? providers.find(
|
? providers.find(
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { Box, Text, color } from 'folds';
|
import { Box, Text, color } from 'folds';
|
||||||
import { Link, useSearchParams } from 'react-router-dom';
|
import { Link, useSearchParams } from 'react-router-dom';
|
||||||
|
import { SSOAction } from 'matrix-js-sdk';
|
||||||
import { useAuthFlows } from '../../../hooks/useAuthFlows';
|
import { useAuthFlows } from '../../../hooks/useAuthFlows';
|
||||||
import { useAuthServer } from '../../../hooks/useAuthServer';
|
import { useAuthServer } from '../../../hooks/useAuthServer';
|
||||||
import { useParsedLoginFlows } from '../../../hooks/useParsedLoginFlows';
|
import { useParsedLoginFlows } from '../../../hooks/useParsedLoginFlows';
|
||||||
|
@ -76,6 +77,7 @@ export function Login() {
|
||||||
<SSOLogin
|
<SSOLogin
|
||||||
providers={parsedFlows.sso.identity_providers}
|
providers={parsedFlows.sso.identity_providers}
|
||||||
redirectUrl={ssoRedirectUrl}
|
redirectUrl={ssoRedirectUrl}
|
||||||
|
action={SSOAction.LOGIN}
|
||||||
saveScreenSpace={parsedFlows.password !== undefined}
|
saveScreenSpace={parsedFlows.password !== undefined}
|
||||||
/>
|
/>
|
||||||
<span data-spacing-node />
|
<span data-spacing-node />
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { Box, Text, color } from 'folds';
|
import { Box, Text, color } from 'folds';
|
||||||
import { Link, useSearchParams } from 'react-router-dom';
|
import { Link, useSearchParams } from 'react-router-dom';
|
||||||
|
import { SSOAction } from 'matrix-js-sdk';
|
||||||
import { useAuthServer } from '../../../hooks/useAuthServer';
|
import { useAuthServer } from '../../../hooks/useAuthServer';
|
||||||
import { RegisterFlowStatus, useAuthFlows } from '../../../hooks/useAuthFlows';
|
import { RegisterFlowStatus, useAuthFlows } from '../../../hooks/useAuthFlows';
|
||||||
import { useParsedLoginFlows } from '../../../hooks/useParsedLoginFlows';
|
import { useParsedLoginFlows } from '../../../hooks/useParsedLoginFlows';
|
||||||
|
@ -83,6 +84,7 @@ export function Register() {
|
||||||
<SSOLogin
|
<SSOLogin
|
||||||
providers={sso.identity_providers}
|
providers={sso.identity_providers}
|
||||||
redirectUrl={ssoRedirectUrl}
|
redirectUrl={ssoRedirectUrl}
|
||||||
|
action={SSOAction.REGISTER}
|
||||||
saveScreenSpace={registerFlows.status === RegisterFlowStatus.FlowRequired}
|
saveScreenSpace={registerFlows.status === RegisterFlowStatus.FlowRequired}
|
||||||
/>
|
/>
|
||||||
<span data-spacing-node />
|
<span data-spacing-node />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue