-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into use-refine-options-title
- Loading branch information
Showing
59 changed files
with
204 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
'use client' | ||
|
||
import React, { | ||
PropsWithChildren, | ||
type PropsWithChildren, | ||
createContext, | ||
useEffect, | ||
useState, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...e-nextjs/plugins/auth-provider-custom/src/providers/auth-provider/auth-provider.server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
refine-nextjs/plugins/auth-provider-keycloak/src/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
refine-nextjs/plugins/data-provider-appwrite/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ | ||
"dependencies": { | ||
"@refinedev/appwrite": "^6.4.6", | ||
"uuid": "^9.0.0", | ||
"js-cookie": "^3.0.5" | ||
}, | ||
"devDependencies": { | ||
"@types/uuid": "^9.0.2", | ||
"@types/js-cookie": "^3.0.6" | ||
} | ||
"dependencies": { | ||
"@refinedev/appwrite": "^6.4.6", | ||
"uuid": "^9.0.0", | ||
"js-cookie": "^3.0.5", | ||
"node-appwrite": "^13.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/uuid": "^9.0.2", | ||
"@types/js-cookie": "^3.0.6" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 13 additions & 13 deletions
26
...nextjs/plugins/data-provider-appwrite/src/providers/auth-provider/auth-provider.server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { AuthBindings } from "@refinedev/core"; | ||
import { APPWRITE_TOKEN_KEY } from "@utility/constants"; | ||
import { cookies } from "next/headers"; | ||
import type { AuthProvider } from "@refinedev/core"; | ||
import { getSessionClient } from "@utils/appwrite/server"; | ||
|
||
export const authProviderServer: Pick<AuthBindings, "check"> = { | ||
export const authProviderServer: Pick<AuthProvider, "check"> = { | ||
check: async () => { | ||
const cookieStore = cookies(); | ||
const auth = cookieStore.get(APPWRITE_TOKEN_KEY); | ||
try { | ||
const client = await getSessionClient(); | ||
await client.account.get(); | ||
|
||
if (auth) { | ||
return { | ||
authenticated: true, | ||
}; | ||
} catch (error: any) { | ||
return { | ||
authenticated: false, | ||
logout: true, | ||
redirectTo: "/login", | ||
error, | ||
}; | ||
} | ||
|
||
return { | ||
authenticated: false, | ||
logout: true, | ||
redirectTo: "/login", | ||
}; | ||
}, | ||
}; |
2 changes: 1 addition & 1 deletion
2
refine-nextjs/plugins/data-provider-appwrite/src/providers/auth-provider/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './auth-provider' | ||
export * from './auth-provider.client' | ||
export * from './auth-provider.server' |
34 changes: 4 additions & 30 deletions
34
refine-nextjs/plugins/data-provider-appwrite/src/providers/data-provider/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,12 @@ | ||
"use client"; | ||
|
||
import { | ||
Account, | ||
Appwrite, | ||
dataProvider as appwriteDataProvider, | ||
liveProvider as appwriteLiveProvider, | ||
Storage, | ||
} from "@refinedev/appwrite"; | ||
import { | ||
APPWRITE_PROJECT, | ||
APPWRITE_TOKEN_KEY, | ||
APPWRITE_URL, | ||
} from "@utility/constants"; | ||
import Cookies from "js-cookie"; | ||
import { dataProvider, liveProvider } from "@refinedev/appwrite"; | ||
import { appwriteClient } from "@utils/appwrite/client"; | ||
|
||
const appwriteClient = new Appwrite(); | ||
|
||
appwriteClient.setEndpoint(APPWRITE_URL).setProject(APPWRITE_PROJECT); | ||
|
||
// for client side authentication | ||
const appwriteJWT = Cookies.get(APPWRITE_TOKEN_KEY); | ||
if (appwriteJWT) { | ||
appwriteClient.setJWT(appwriteJWT); | ||
} | ||
|
||
const account = new Account(appwriteClient); | ||
const storage = new Storage(appwriteClient); | ||
|
||
export { appwriteClient, account, storage }; | ||
|
||
export const dataProvider = appwriteDataProvider(appwriteClient, { | ||
export const appwriteDataProvider = dataProvider(appwriteClient, { | ||
databaseId: "database", | ||
}); | ||
|
||
export const liveProvider = appwriteLiveProvider(appwriteClient, { | ||
export const appwriteLiveProvider = liveProvider(appwriteClient, { | ||
databaseId: "database", | ||
}); |
17 changes: 17 additions & 0 deletions
17
refine-nextjs/plugins/data-provider-appwrite/src/utils/appwrite/client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use client' | ||
|
||
import { Account, Appwrite, Storage } from '@refinedev/appwrite' | ||
import { APPWRITE_JWT_KEY, APPWRITE_PROJECT, APPWRITE_URL } from '@utils/constants' | ||
import Cookies from 'js-cookie' | ||
|
||
export const appwriteClient = new Appwrite() | ||
|
||
const appwriteJWT = Cookies.get(APPWRITE_JWT_KEY) | ||
if (appwriteJWT) { | ||
appwriteClient.setJWT(appwriteJWT) | ||
} | ||
|
||
appwriteClient.setEndpoint(APPWRITE_URL).setProject(APPWRITE_PROJECT) | ||
|
||
export const appwriteAccount = new Account(appwriteClient) | ||
export const appwriteStorage = new Storage(appwriteClient) |
20 changes: 20 additions & 0 deletions
20
refine-nextjs/plugins/data-provider-appwrite/src/utils/appwrite/server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Client, Account } from 'node-appwrite' | ||
import { cookies } from 'next/headers' | ||
import { APPWRITE_JWT_KEY, APPWRITE_PROJECT, APPWRITE_URL } from '@utils/constants' | ||
|
||
export const getSessionClient = async () => { | ||
const client = new Client().setEndpoint(APPWRITE_URL).setProject(APPWRITE_PROJECT) | ||
|
||
const session = cookies().get(APPWRITE_JWT_KEY) | ||
if (!session || !session.value) { | ||
throw new Error('No session') | ||
} | ||
|
||
client.setJWT(session.value) | ||
|
||
return { | ||
get account() { | ||
return new Account(client) | ||
}, | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...rovider-appwrite/src/utility/constants.ts → ...-provider-appwrite/src/utils/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const APPWRITE_URL = "https://refine.appwrite.org/v1"; | ||
export const APPWRITE_PROJECT = "61c4368b4e349"; | ||
export const APPWRITE_TOKEN_KEY = "appwrite-jwt"; | ||
export const APPWRITE_JWT_KEY = "appwrite-jwt"; |
File renamed without changes.
Oops, something went wrong.