Fix more build errors
This commit is contained in:
parent
1bdc1e60db
commit
30ce47826f
61 changed files with 1161 additions and 541 deletions
|
|
@ -4,22 +4,21 @@ import { signIn, signOut, getSession } from "next-auth/react";
|
|||
import { useLogin, useTranslate } from "react-admin";
|
||||
|
||||
export const authProvider = {
|
||||
login: (o: any) => {
|
||||
login(o: any) {
|
||||
if (o.ok) return Promise.resolve();
|
||||
return Promise.reject();
|
||||
},
|
||||
logout: async () => {
|
||||
async logout() {
|
||||
const session = await getSession();
|
||||
if (session) {
|
||||
await signOut();
|
||||
}
|
||||
},
|
||||
checkError: (e: any) => {
|
||||
checkError(e: any) {
|
||||
if (e.graphQLErrors && e.graphQLErrors.length > 0) {
|
||||
const permDenied =
|
||||
e.graphQLErrors.filter((e: any) =>
|
||||
e.message.match(/.*permission denied.*/)
|
||||
).length > 0;
|
||||
const permDenied = e.graphQLErrors.some((e: any) =>
|
||||
e.message.match(/.*permission denied.*/)
|
||||
);
|
||||
if (permDenied)
|
||||
// eslint-disable-next-line prefer-promise-reject-errors
|
||||
return Promise.reject({ message: "auth.permissionDenied" });
|
||||
|
|
@ -31,17 +30,15 @@ export const authProvider = {
|
|||
|
||||
return Promise.resolve();
|
||||
},
|
||||
checkAuth: async () => {
|
||||
async checkAuth() {
|
||||
const session = await getSession();
|
||||
if (!session) {
|
||||
return Promise.reject();
|
||||
throw new Error("Invalid session");
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
},
|
||||
getIdentity: async () => {
|
||||
async getIdentity() {
|
||||
const session = await getSession();
|
||||
if (!session) return Promise.reject(new Error("Invalid session"));
|
||||
if (!session) throw new Error("Invalid session");
|
||||
|
||||
return {
|
||||
id: session.user?.email,
|
||||
|
|
@ -59,10 +56,10 @@ export const AdminLogin: FC = () => {
|
|||
useEffect(() => {
|
||||
(async () => {
|
||||
const session = await getSession();
|
||||
if (!session) {
|
||||
signIn();
|
||||
} else {
|
||||
if (session) {
|
||||
reactAdminLogin({ ok: true });
|
||||
} else {
|
||||
signIn();
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue