mirror of
https://codeberg.org/MarkusThielker/next-ory.git
synced 2025-07-04 13:59:17 +00:00
NORY-14: refactor Kratos and Hydra APIs (authentication)
This commit is contained in:
parent
215d47e888
commit
9ee7da3a6c
12 changed files with 51 additions and 27 deletions
|
@ -2,11 +2,11 @@
|
|||
|
||||
import React from 'react';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import getHydra from '@/ory/sdk/hydra';
|
||||
import { OAuth2ConsentRequest, OAuth2RedirectTo } from '@ory/client';
|
||||
import ConsentForm from '@/components/consentForm';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { toast } from 'sonner';
|
||||
import { getOAuth2Api } from '@/ory/sdk/server';
|
||||
|
||||
export default async function Consent(props: { searchParams: Promise<{ consent_challenge: string }> }) {
|
||||
|
||||
|
@ -18,7 +18,7 @@ export default async function Consent(props: { searchParams: Promise<{ consent_c
|
|||
const onAccept = async (challenge: string, scopes: string[], remember: boolean) => {
|
||||
'use server';
|
||||
|
||||
const hydra = await getHydra();
|
||||
const hydra = await getOAuth2Api();
|
||||
const response = await hydra
|
||||
.acceptOAuth2ConsentRequest({
|
||||
consentChallenge: challenge,
|
||||
|
@ -43,7 +43,7 @@ export default async function Consent(props: { searchParams: Promise<{ consent_c
|
|||
const onReject = async (challenge: string) => {
|
||||
'use server';
|
||||
|
||||
const hydra = await getHydra();
|
||||
const hydra = await getOAuth2Api();
|
||||
const response: OAuth2RedirectTo | void = await hydra
|
||||
.rejectOAuth2ConsentRequest({
|
||||
consentChallenge: challenge,
|
||||
|
@ -64,7 +64,7 @@ export default async function Consent(props: { searchParams: Promise<{ consent_c
|
|||
return;
|
||||
}
|
||||
|
||||
const hydra = await getHydra();
|
||||
const hydra = await getOAuth2Api();
|
||||
await hydra
|
||||
.getOAuth2ConsentRequest({ consentChallenge })
|
||||
.then(({ data }) => {
|
||||
|
|
|
@ -4,7 +4,7 @@ import React, { useEffect, useState } from 'react';
|
|||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { FlowError } from '@ory/client';
|
||||
import { AxiosError } from 'axios';
|
||||
import { kratos } from '@/ory/sdk/kratos';
|
||||
import { kratos } from '../../../ory/sdk/client';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import Link from 'next/link';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
|
|||
import { Flow, HandleError, LogoutLink } from '@/ory';
|
||||
import Link from 'next/link';
|
||||
import { LoginFlow, UpdateLoginFlowBody } from '@ory/client';
|
||||
import { kratos } from '@/ory/sdk/kratos';
|
||||
import { kratos } from '../../../ory/sdk/client';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import Image from 'next/image';
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
|
|||
import { Flow, HandleError } from '@/ory';
|
||||
import { RecoveryFlow, UpdateRecoveryFlowBody } from '@ory/client';
|
||||
import { AxiosError } from 'axios';
|
||||
import { kratos } from '@/ory/sdk/kratos';
|
||||
import { kratos } from '../../../ory/sdk/client';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import Link from 'next/link';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
|
|
@ -6,7 +6,7 @@ import { Flow, HandleError } from '@/ory';
|
|||
import Link from 'next/link';
|
||||
import { RegistrationFlow, UpdateRegistrationFlowBody } from '@ory/client';
|
||||
import { AxiosError } from 'axios';
|
||||
import { kratos } from '@/ory/sdk/kratos';
|
||||
import { kratos } from '../../../ory/sdk/client';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
|
|
|
@ -5,7 +5,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
|
|||
import { Flow, HandleError } from '@/ory';
|
||||
import { UpdateVerificationFlowBody, VerificationFlow } from '@ory/client';
|
||||
import { AxiosError } from 'axios';
|
||||
import { kratos } from '@/ory/sdk/kratos';
|
||||
import { kratos } from '../../../ory/sdk/client';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import Link from 'next/link';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue