mirror of
https://github.com/outline/outline.git
synced 2026-01-06 02:59:54 -06:00
This PR contains the necessary work to make Outline an OAuth provider including: - OAuth app registration - OAuth app management - Private / public apps (Public in cloud only) - Full OAuth 2.0 spec compatible authentication flow - Granular scopes - User token management screen in settings - Associated API endpoints for programatic access
34 lines
932 B
TypeScript
34 lines
932 B
TypeScript
import { observer } from "mobx-react";
|
|
import * as React from "react";
|
|
import { useHistory } from "react-router-dom";
|
|
import { toast } from "sonner";
|
|
import useStores from "~/hooks/useStores";
|
|
import { settingsPath } from "~/utils/routeHelpers";
|
|
import { OAuthClientForm, FormData } from "./OAuthClientForm";
|
|
|
|
type Props = {
|
|
onSubmit: () => void;
|
|
};
|
|
|
|
export const OAuthClientNew = observer(function OAuthClientNew_({
|
|
onSubmit,
|
|
}: Props) {
|
|
const { oauthClients } = useStores();
|
|
const history = useHistory();
|
|
|
|
const handleSubmit = React.useCallback(
|
|
async (data: FormData) => {
|
|
try {
|
|
const oauthClient = await oauthClients.save(data);
|
|
onSubmit?.();
|
|
history.push(settingsPath("applications", oauthClient.id));
|
|
} catch (error) {
|
|
toast.error(error.message);
|
|
}
|
|
},
|
|
[oauthClients, history, onSubmit]
|
|
);
|
|
|
|
return <OAuthClientForm handleSubmit={handleSubmit} />;
|
|
});
|