mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
NextJS Fief Auth (Draft)
This commit is contained in:
@@ -55,6 +55,10 @@ export interface V1TranscriptGetAudioRequest {
|
|||||||
transcriptId: any;
|
transcriptId: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface V1TranscriptGetAudioMp3Request {
|
||||||
|
transcriptId: any;
|
||||||
|
}
|
||||||
|
|
||||||
export interface V1TranscriptGetTopicsRequest {
|
export interface V1TranscriptGetTopicsRequest {
|
||||||
transcriptId: any;
|
transcriptId: any;
|
||||||
}
|
}
|
||||||
@@ -159,6 +163,14 @@ export class DefaultApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
const headerParameters: runtime.HTTPHeaders = {};
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
headerParameters["Authorization"] = await this.configuration.accessToken(
|
||||||
|
"OAuth2AuthorizationCodeBearer",
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const response = await this.request(
|
const response = await this.request(
|
||||||
{
|
{
|
||||||
path: `/v1/transcripts/{transcript_id}`.replace(
|
path: `/v1/transcripts/{transcript_id}`.replace(
|
||||||
@@ -212,6 +224,14 @@ export class DefaultApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
const headerParameters: runtime.HTTPHeaders = {};
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
headerParameters["Authorization"] = await this.configuration.accessToken(
|
||||||
|
"OAuth2AuthorizationCodeBearer",
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const response = await this.request(
|
const response = await this.request(
|
||||||
{
|
{
|
||||||
path: `/v1/transcripts/{transcript_id}`.replace(
|
path: `/v1/transcripts/{transcript_id}`.replace(
|
||||||
@@ -299,6 +319,61 @@ export class DefaultApi extends runtime.BaseAPI {
|
|||||||
return await response.value();
|
return await response.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transcript Get Audio Mp3
|
||||||
|
*/
|
||||||
|
async v1TranscriptGetAudioMp3Raw(
|
||||||
|
requestParameters: V1TranscriptGetAudioMp3Request,
|
||||||
|
initOverrides?: RequestInit | runtime.InitOverrideFunction,
|
||||||
|
): Promise<runtime.ApiResponse<any>> {
|
||||||
|
if (
|
||||||
|
requestParameters.transcriptId === null ||
|
||||||
|
requestParameters.transcriptId === undefined
|
||||||
|
) {
|
||||||
|
throw new runtime.RequiredError(
|
||||||
|
"transcriptId",
|
||||||
|
"Required parameter requestParameters.transcriptId was null or undefined when calling v1TranscriptGetAudioMp3.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParameters: any = {};
|
||||||
|
|
||||||
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
const response = await this.request(
|
||||||
|
{
|
||||||
|
path: `/v1/transcripts/{transcript_id}/audio/mp3`.replace(
|
||||||
|
`{${"transcript_id"}}`,
|
||||||
|
encodeURIComponent(String(requestParameters.transcriptId)),
|
||||||
|
),
|
||||||
|
method: "GET",
|
||||||
|
headers: headerParameters,
|
||||||
|
query: queryParameters,
|
||||||
|
},
|
||||||
|
initOverrides,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.isJsonMime(response.headers.get("content-type"))) {
|
||||||
|
return new runtime.JSONApiResponse<any>(response);
|
||||||
|
} else {
|
||||||
|
return new runtime.TextApiResponse(response) as any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transcript Get Audio Mp3
|
||||||
|
*/
|
||||||
|
async v1TranscriptGetAudioMp3(
|
||||||
|
requestParameters: V1TranscriptGetAudioMp3Request,
|
||||||
|
initOverrides?: RequestInit | runtime.InitOverrideFunction,
|
||||||
|
): Promise<any> {
|
||||||
|
const response = await this.v1TranscriptGetAudioMp3Raw(
|
||||||
|
requestParameters,
|
||||||
|
initOverrides,
|
||||||
|
);
|
||||||
|
return await response.value();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transcript Get Topics
|
* Transcript Get Topics
|
||||||
*/
|
*/
|
||||||
@@ -510,6 +585,14 @@ export class DefaultApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
headerParameters["Content-Type"] = "application/json";
|
headerParameters["Content-Type"] = "application/json";
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
headerParameters["Authorization"] = await this.configuration.accessToken(
|
||||||
|
"OAuth2AuthorizationCodeBearer",
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const response = await this.request(
|
const response = await this.request(
|
||||||
{
|
{
|
||||||
path: `/v1/transcripts/{transcript_id}`.replace(
|
path: `/v1/transcripts/{transcript_id}`.replace(
|
||||||
@@ -566,6 +649,14 @@ export class DefaultApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
headerParameters["Content-Type"] = "application/json";
|
headerParameters["Content-Type"] = "application/json";
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
headerParameters["Authorization"] = await this.configuration.accessToken(
|
||||||
|
"OAuth2AuthorizationCodeBearer",
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const response = await this.request(
|
const response = await this.request(
|
||||||
{
|
{
|
||||||
path: `/v1/transcripts`,
|
path: `/v1/transcripts`,
|
||||||
@@ -615,6 +706,14 @@ export class DefaultApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
const headerParameters: runtime.HTTPHeaders = {};
|
const headerParameters: runtime.HTTPHeaders = {};
|
||||||
|
|
||||||
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
|
// oauth required
|
||||||
|
headerParameters["Authorization"] = await this.configuration.accessToken(
|
||||||
|
"OAuth2AuthorizationCodeBearer",
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const response = await this.request(
|
const response = await this.request(
|
||||||
{
|
{
|
||||||
path: `/v1/transcripts`,
|
path: `/v1/transcripts`,
|
||||||
|
|||||||
11
www/app/fiefWrapper.tsx
Normal file
11
www/app/fiefWrapper.tsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { FiefAuthProvider } from "@fief/fief/nextjs/react";
|
||||||
|
|
||||||
|
export default function FiefWrapper({ children }) {
|
||||||
|
return (
|
||||||
|
<FiefAuthProvider currentUserPath="/api/current-user">
|
||||||
|
{children}
|
||||||
|
</FiefAuthProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
import "./styles/globals.scss";
|
import "./styles/globals.scss";
|
||||||
import { Roboto } from "next/font/google";
|
import { Roboto } from "next/font/google";
|
||||||
import { Metadata } from "next";
|
import { Metadata } from "next";
|
||||||
import { FiefAuthProvider } from "@fief/fief/nextjs/react";
|
import FiefWrapper from "./fiefWrapper";
|
||||||
|
import UserInfo from "./userInfo";
|
||||||
|
|
||||||
const roboto = Roboto({ subsets: ["latin"], weight: "400" });
|
const roboto = Roboto({ subsets: ["latin"], weight: "400" });
|
||||||
|
|
||||||
@@ -51,14 +52,13 @@ export const metadata: Metadata = {
|
|||||||
|
|
||||||
export default function RootLayout({ children }) {
|
export default function RootLayout({ children }) {
|
||||||
return (
|
return (
|
||||||
<FiefAuthProvider currentUserPath="/api/current-user">
|
<html lang="en">
|
||||||
{" "}
|
<body className={roboto.className + " flex flex-col min-h-screen"}>
|
||||||
{}
|
<FiefWrapper>
|
||||||
<html lang="en">
|
<UserInfo />
|
||||||
<body className={roboto.className + " flex flex-col min-h-screen"}>
|
|
||||||
{children}
|
{children}
|
||||||
</body>
|
</FiefWrapper>
|
||||||
</html>
|
</body>
|
||||||
</FiefAuthProvider>
|
</html>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
"use client";
|
||||||
import { Fief, FiefUserInfo } from "@fief/fief";
|
import { Fief, FiefUserInfo } from "@fief/fief";
|
||||||
import { FiefAuth, IUserInfoCache } from "@fief/fief/nextjs";
|
import { FiefAuth, IUserInfoCache } from "@fief/fief/nextjs";
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const useTranscript = (): UseTranscript => {
|
|||||||
|
|
||||||
const apiConfiguration = new Configuration({
|
const apiConfiguration = new Configuration({
|
||||||
basePath: process.env.NEXT_PUBLIC_API_URL,
|
basePath: process.env.NEXT_PUBLIC_API_URL,
|
||||||
|
// accessToken:
|
||||||
});
|
});
|
||||||
const api = new DefaultApi(apiConfiguration);
|
const api = new DefaultApi(apiConfiguration);
|
||||||
|
|
||||||
|
|||||||
23
www/app/userInfo.tsx
Normal file
23
www/app/userInfo.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
"use client";
|
||||||
|
import { useFiefUserinfo } from "@fief/fief/nextjs/react";
|
||||||
|
|
||||||
|
export default function UserInfo() {
|
||||||
|
const userinfo = useFiefUserinfo();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{userinfo && (
|
||||||
|
<>
|
||||||
|
<h1>Logged In</h1>
|
||||||
|
<p>{userinfo.email}</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!userinfo && (
|
||||||
|
<>
|
||||||
|
<h1>Not Logged In</h1>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user