mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-09 16:50:28 +03:00
fix sso login without identity providers (#1934)
This commit is contained in:
parent
c6a8fb1117
commit
09444f9e08
4 changed files with 72 additions and 63 deletions
|
|
@ -1,16 +1,10 @@
|
|||
import { useMemo } from 'react';
|
||||
import { ILoginFlow, IPasswordFlow, ISSOFlow, LoginFlow } from 'matrix-js-sdk/lib/@types/auth';
|
||||
import { WithRequiredProp } from '../../types/utils';
|
||||
|
||||
export type Required_SSOFlow = WithRequiredProp<ISSOFlow, 'identity_providers'>;
|
||||
export const getSSOFlow = (loginFlows: LoginFlow[]): Required_SSOFlow | undefined =>
|
||||
loginFlows.find(
|
||||
(flow) =>
|
||||
(flow.type === 'm.login.sso' || flow.type === 'm.login.cas') &&
|
||||
'identity_providers' in flow &&
|
||||
Array.isArray(flow.identity_providers) &&
|
||||
flow.identity_providers.length > 0
|
||||
) as Required_SSOFlow | undefined;
|
||||
export const getSSOFlow = (loginFlows: LoginFlow[]): ISSOFlow | undefined =>
|
||||
loginFlows.find((flow) => flow.type === 'm.login.sso' || flow.type === 'm.login.cas') as
|
||||
| ISSOFlow
|
||||
| undefined;
|
||||
|
||||
export const getPasswordFlow = (loginFlows: LoginFlow[]): IPasswordFlow | undefined =>
|
||||
loginFlows.find((flow) => flow.type === 'm.login.password') as IPasswordFlow;
|
||||
|
|
@ -22,7 +16,7 @@ export const getTokenFlow = (loginFlows: LoginFlow[]): LoginFlow | undefined =>
|
|||
export type ParsedLoginFlows = {
|
||||
password?: LoginFlow;
|
||||
token?: LoginFlow;
|
||||
sso?: Required_SSOFlow;
|
||||
sso?: ISSOFlow;
|
||||
};
|
||||
export const useParsedLoginFlows = (loginFlows: LoginFlow[]) => {
|
||||
const parsedFlow: ParsedLoginFlows = useMemo<ParsedLoginFlows>(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue