mirror of
https://github.com/wassname/talk.git
synced 2026-09-11 12:51:33 +08:00
[next] Admin Authentication (#2155)
* feat: Support sign in via E-Mail, and social logins + permission check * feat: no permission info * test: unit test * test: fix remaining tests * test: add integration tests * feat: add admin account completion * test: auth completion feature tests * fix: translation * fix: comment marker design * fix: linting issues * chore: address pr review comments * chore: add comment
This commit is contained in:
@@ -58,7 +58,7 @@ export interface TalkContext {
|
||||
eventEmitter: EventEmitter2;
|
||||
|
||||
/** Clear session data. */
|
||||
clearSession: () => void;
|
||||
clearSession: () => Promise<void>;
|
||||
}
|
||||
|
||||
const { Provider, Consumer } = React.createContext<TalkContext>({} as any);
|
||||
|
||||
@@ -251,7 +251,7 @@ export default async function createManaged({
|
||||
uuidGenerator: uuid,
|
||||
// Noop, this is later replaced by the
|
||||
// managed TalkContextProvider.
|
||||
clearSession: noop,
|
||||
clearSession: () => Promise.resolve(),
|
||||
};
|
||||
|
||||
// Initialize local state.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { default as withRouteConfig } from "./withRouteConfig";
|
||||
@@ -0,0 +1,33 @@
|
||||
import { RouteProps } from "found";
|
||||
import * as React from "react";
|
||||
|
||||
interface InjectedProps<T> {
|
||||
error?: Error | null;
|
||||
data: T | null | undefined;
|
||||
retry?: Error | null;
|
||||
}
|
||||
|
||||
type RouteConfig = Pick<RouteProps, "query"> &
|
||||
Partial<Pick<RouteProps, "data" | "getData" | "defer">> & {
|
||||
cacheConfig?: {
|
||||
force?: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
function withRouteConfig<QueryResponse>(config: RouteConfig) {
|
||||
const hoc = <T extends InjectedProps<QueryResponse>>(
|
||||
component: React.ComponentType<T>
|
||||
) => {
|
||||
(component as any).routeConfig = {
|
||||
...config,
|
||||
Component: component,
|
||||
render: ({ error, props, retry, Component }: any) => {
|
||||
return React.createElement(Component, { error, data: props, retry });
|
||||
},
|
||||
};
|
||||
return component as React.ComponentClass<T> & { routeConfig: RouteConfig };
|
||||
};
|
||||
return hoc;
|
||||
}
|
||||
|
||||
export default withRouteConfig;
|
||||
Reference in New Issue
Block a user