|
1 | | -<h1 align="center" style="border-bottom: none"> |
2 | | - <b> |
3 | | - <a href="https://www.appflowy.com">AppFlowy</a><br> |
4 | | - </b> |
5 | | - ⭐️ The Open Source Alternative To Notion ⭐️ <br> |
6 | | -</h1> |
7 | | - |
8 | | -<p align="center"> |
9 | | -AppFlowy is the AI workspace where you achieve more without losing control of your data |
10 | | -</p> |
11 | | - |
12 | | -<p align="center"> |
13 | | -<a href="https://discord.gg/9Q2xaN37tV"><img src="https://img.shields.io/badge/AppFlowy.IO-discord-orange"></a> |
14 | | -<a href="https://github.com/AppFlowy-IO/appflowy"><img src="https://img.shields.io/github/stars/AppFlowy-IO/appflowy.svg?style=flat&logo=github&colorB=deeppink&label=stars"></a> |
15 | | -<a href="https://github.com/AppFlowy-IO/appflowy"><img src="https://img.shields.io/github/forks/AppFlowy-IO/appflowy.svg"></a> |
16 | | -<a href="https://opensource.org/licenses/AGPL-3.0"><img src="https://img.shields.io/badge/license-AGPL-purple.svg" alt="License: AGPL"></a> |
17 | | - |
18 | | -</p> |
19 | | - |
20 | | -<p align="center"> |
21 | | - <a href="https://www.appflowy.com"><b>Website</b></a> • |
22 | | - <a href="https://forum.appflowy.io/"><b>Forum</b></a> • |
23 | | - <a href="https://discord.gg/9Q2xaN37tV"><b>Discord</b></a> • |
24 | | - <a href="https://www.reddit.com/r/AppFlowy"><b>Reddit</b></a> • |
25 | | - <a href="https://twitter.com/appflowy"><b>Twitter</b></a> |
26 | | -</p> |
27 | | - |
28 | | -<p align="center"><img src="https://appflowy.com/_next/static/media/tasks.796c753e.png" alt="AppFlowy Kanban Board for To-dos" /></p> |
29 | | -<p align="center"><img src="https://appflowy.com/_next/static/media/Grid.9e30484b.png" alt="AppFlowy Databases for Tasks and Projects" /></p> |
30 | | -<p align="center"><img src="https://appflowy.com/_next/static/media/sites.a8d5b2b9.png" alt="AppFlowy Sites for Beautiful documentation" /></p> |
31 | | -<p align="center"><img src="https://appflowy.com/_next/static/media/ai.e1460982.png" alt="AppFlowy AI" /></p> |
32 | | -<p align="center"><img src="https://appflowy.com/_next/static/media/template.9ea13c3b.png" alt="AppFlowy Templates" /></p> |
33 | | - |
34 | | -<br></br> |
35 | | -<p align="center" > |
36 | | - <img src="https://github.com/user-attachments/assets/5841c491-b564-4a26-b9b6-191def430911" alt="Work across devices" width="1040px" /></p> |
37 | | -<p align="center" > |
38 | | - <img src="https://github.com/user-attachments/assets/c2ba6bb8-746c-4743-9393-d008a669be95" alt="Work across devices" width="1040px" /></p> |
39 | | -<p align="center" > |
40 | | - <img src="https://github.com/user-attachments/assets/e83dd1a3-4975-4d0e-91a1-9eb6e0d248cd" alt="Work across devices" width="1040px" /></p> |
41 | | - |
42 | | -## User Installation |
43 | | - |
44 | | -- [Download AppFlowy Desktop (macOS, Windows, and Linux)](https://github.com/AppFlowy-IO/AppFlowy/releases) |
45 | | -- Other |
46 | | - channels: [FlatHub](https://flathub.org/apps/io.appflowy.AppFlowy), [Snapcraft](https://snapcraft.io/appflowy), [Sourceforge](https://sourceforge.net/projects/appflowy/) |
47 | | -- Available on |
48 | | - - [App Store](https://apps.apple.com/app/appflowy/id6457261352): iPhone |
49 | | - - [Play Store](https://play.google.com/store/apps/details?id=io.appflowy.appflowy): Android 10 or above; ARMv7 is |
50 | | - not supported |
51 | | -- [Self-hosting AppFlowy](https://appflowy.com/docs/self-host-appflowy-overview) |
52 | | -- [Source](https://docs.appflowy.io/docs/documentation/appflowy/from-source) |
53 | | - |
54 | | -## Built With |
55 | | - |
56 | | -- [Flutter](https://flutter.dev/) |
57 | | - |
58 | | -- [Rust](https://www.rust-lang.org/) |
59 | | - |
60 | | -## Stay Up-to-Date |
61 | | - |
62 | | -<p align="center"><img src="https://github.com/AppFlowy-IO/appflowy/blob/main/doc/imgs/howtostar.gif" alt="AppFlowy Github - how to star the repo" width="100%" /></p> |
63 | | - |
64 | | -## Getting Started with development |
65 | | - |
66 | | -Please view the [documentation](https://docs.appflowy.io/docs/documentation/appflowy/from-source) for OS specific |
67 | | -development instructions |
68 | | - |
69 | | -## Roadmap |
70 | | - |
71 | | -- [AppFlowy Roadmap ReadMe](https://docs.appflowy.io/docs/appflowy/roadmap) |
72 | | -- [AppFlowy Public Roadmap](https://github.com/orgs/AppFlowy-IO/projects/5/views/12) |
73 | | - |
74 | | -If you'd like to propose a feature, submit a feature |
75 | | -request [here](https://github.com/AppFlowy-IO/AppFlowy/issues/new?assignees=&labels=&template=feature_request.yaml&title=%5BFR%5D+) <br/> |
76 | | -If you'd like to report a bug, submit a bug |
77 | | -report [here](https://github.com/AppFlowy-IO/AppFlowy/issues/new?assignees=&labels=&template=bug_report.yaml&title=%5BBug%5D+) |
78 | | - |
79 | | -## **Releases** |
80 | | - |
81 | | -Please see the [changelog](https://appflowy.com/what-is-new) for more details about a given release. |
82 | | - |
83 | | -## Contributing |
84 | | - |
85 | | -Contributions make the open-source community a fantastic place to learn, inspire, and create. Any contributions you make |
86 | | -are **greatly appreciated**. Please look |
87 | | -at [Contributing to AppFlowy](https://docs.appflowy.io/docs/documentation/software-contributions/contributing-to-appflowy) |
88 | | -for details. |
89 | | - |
90 | | -If your Pull Request is accepted as it fixes a bug, adds functionality, or makes AppFlowy's codebase significantly |
91 | | -easier to use or understand, **Congratulations!** If your administrative and managerial work behind the scenes sustains |
92 | | -the community, **Congratulations!** You are now an official contributor to AppFlowy. |
93 | | - |
94 | | -## Translations 🌎🗺 |
95 | | - |
96 | | -[](https://inlang.com/editor/github.com/AppFlowy-IO/AppFlowy?ref=badge) |
97 | | - |
98 | | -To add translations, you can manually edit the JSON translation files in `/frontend/resources/translations`, use |
99 | | -the [inlang online editor](https://inlang.com/editor/github.com/AppFlowy-IO/AppFlowy), or |
100 | | -run `npx inlang machine translate` to add missing translations. |
101 | | - |
102 | | -## Join the community to build AppFlowy together |
103 | | - |
104 | | -<a href="https://github.com/AppFlowy-IO/AppFlowy/graphs/contributors"> |
105 | | - <img src="https://contrib.rocks/image?repo=AppFlowy-IO/AppFlowy" /> |
106 | | -</a> |
107 | | - |
108 | | -## Why Are We Building This? |
109 | | - |
110 | | -Notion has been our favourite project and knowledge management tool in recent years because of its aesthetic appeal and |
111 | | -functionality. Our team uses it daily, and we are on its paid plan. However, as we all know, Notion has its limitations. |
112 | | -These include weak data security and poor compatibility with mobile devices. Likewise, alternative collaborative |
113 | | -workplace management tools also have their constraints. |
114 | | - |
115 | | -The limitations we encountered using these tools and our past work experience with collaborative productivity tools have |
116 | | -led to our firm belief that there is a glass ceiling on what's possible for these tools in the future. This emanates |
117 | | -from the fact that these tools will probably struggle to scale horizontally at some point and be forced to prioritize a |
118 | | -proportion of customers whose needs differ from the rest. While decision-makers want a workplace OS, it is impossible to |
119 | | -come up with a one-size fits all solution in such a fragmented market. |
120 | | - |
121 | | -When a customer's evolving core needs are not satisfied, they either switch to another or build one from the ground up, |
122 | | -in-house. Consequently, they either go under another ceiling or buy an expensive ticket to learn a hard lesson. This is |
123 | | -a requirement for many resources and expertise, building a reliable and easy-to-use collaborative tool, not to mention |
124 | | -the speed and native experience. The same may apply to individual users as well. |
125 | | - |
126 | | -All these restrictions necessitate our mission - to make it possible for anyone to create apps that suit their needs |
127 | | -well. |
128 | | - |
129 | | -- To individuals, we would like to offer Notion's functionality, data security, and cross-platform native experience. |
130 | | -- To enterprises and hackers, AppFlowy is dedicated to offering building blocks and collaboration infra services to |
131 | | - enable you to make apps on your own. Moreover, you have 100% control of your data. You can design and modify AppFlowy |
132 | | - your way, with a single codebase written in Flutter and Rust supporting multiple platforms armed with long-term |
133 | | - maintainability. |
134 | | - |
135 | | -We decided to achieve this mission by upholding the three most fundamental values: |
136 | | - |
137 | | -- Data privacy first |
138 | | -- Reliable native experience |
139 | | -- Community-driven extensibility |
140 | | - |
141 | | -We do not claim to outperform Notion in terms of functionality and design, at least for now. Besides, our priority |
142 | | -doesn't lie in more functionality at the moment. Instead, we would like to cultivate a community to democratize the |
143 | | -knowledge and wheels of making complex workplace management tools while enabling people and businesses to create |
144 | | -beautiful things on their own by equipping them with a versatile toolbox of building blocks. |
145 | | - |
146 | | -## License |
147 | | - |
148 | | -Distributed under the AGPLv3 License. See [`LICENSE.md`](https://github.com/AppFlowy-IO/AppFlowy/blob/main/LICENSE) for |
149 | | -more information. |
150 | | - |
151 | | -## Acknowledgments |
152 | | - |
153 | | -Special thanks to these amazing projects which help power AppFlowy: |
154 | | - |
155 | | -- [cargo-make](https://github.com/sagiegurari/cargo-make) |
156 | | -- [contrib.rocks](https://contrib.rocks) |
157 | | -- [flutter_chat_ui](https://pub.dev/packages/flutter_chat_ui) |
| 1 | +// authProvider.ts (or your custom auth provider file) |
| 2 | + |
| 3 | +import { AuthProvider } from "@refinedev/core"; |
| 4 | + |
| 5 | +// Define a simple structure for your user identity data |
| 6 | +interface UserIdentity { |
| 7 | + id: number; |
| 8 | + name: string; |
| 9 | + email: string; |
| 10 | + // Add other fields your app uses |
| 11 | +} |
| 12 | + |
| 13 | +const authProvider: AuthProvider = { |
| 14 | + login: async ({ email, password }) => { |
| 15 | + // 1. Send credentials to your backend API |
| 16 | + // This is a placeholder for your actual API call (e.g., using axios/fetch) |
| 17 | + const response = await fetch("YOUR_API_BASE_URL/auth/login", { |
| 18 | + method: "POST", |
| 19 | + headers: { "Content-Type": "application/json" }, |
| 20 | + body: JSON.stringify({ email, password }), |
| 21 | + }); |
| 22 | + |
| 23 | + const data = await response.json(); |
| 24 | + |
| 25 | + if (response.ok && data.token) { |
| 26 | + // 2. Store the token on successful login |
| 27 | + localStorage.setItem("authToken", data.token); |
| 28 | + |
| 29 | + // Success response |
| 30 | + return { |
| 31 | + success: true, |
| 32 | + redirectTo: "/", // Redirect to the home page |
| 33 | + }; |
| 34 | + } |
| 35 | + |
| 36 | + // Failed login attempt |
| 37 | + return { |
| 38 | + success: false, |
| 39 | + error: new Error(data.message || "Login failed. Check your credentials."), |
| 40 | + }; |
| 41 | + }, |
| 42 | + |
| 43 | + logout: async (params) => { |
| 44 | + // Clear the token and any user data |
| 45 | + localStorage.removeItem("authToken"); |
| 46 | + localStorage.removeItem("user"); |
| 47 | + |
| 48 | + // Success response |
| 49 | + return { |
| 50 | + success: true, |
| 51 | + redirectTo: "/login", // Always redirect to the login page |
| 52 | + }; |
| 53 | + }, |
| 54 | + |
| 55 | + checkAuth: async (params) => { |
| 56 | + const token = localStorage.getItem("authToken"); |
| 57 | + |
| 58 | + if (token) { |
| 59 | + // User is authenticated |
| 60 | + return { |
| 61 | + authenticated: true, |
| 62 | + }; |
| 63 | + } |
| 64 | + |
| 65 | + // User is not authenticated, redirect to login |
| 66 | + return { |
| 67 | + authenticated: false, |
| 68 | + redirectTo: "/login", |
| 69 | + }; |
| 70 | + }, |
| 71 | + |
| 72 | + getIdentity: async () => { |
| 73 | + const user = localStorage.getItem("user"); |
| 74 | + |
| 75 | + if (user) { |
| 76 | + // Return parsed user identity |
| 77 | + return JSON.parse(user) as UserIdentity; |
| 78 | + } |
| 79 | + |
| 80 | + // If identity is not found, return null or throw error if session is strictly required |
| 81 | + return null; |
| 82 | + }, |
| 83 | + |
| 84 | + // 🌟 FIX FOR THE INFINITE LOOP BUG (Issue #6997) 🌟 |
| 85 | + onError: async (error) => { |
| 86 | + // Ensure we can extract a status code from the error object |
| 87 | + const status = (error as any)?.statusCode || (error as any)?.response?.status; |
| 88 | + |
| 89 | + // Check for Unauthorized (401) or Forbidden (403) status codes |
| 90 | + if (status === 401 || status === 403) { |
| 91 | + // The crucial fix is returning `{ logout: true }`. |
| 92 | + // This instructs Refine's core to call the 'logout' method, |
| 93 | + // which handles clearing the session and redirecting, preventing the loop. |
| 94 | + return { |
| 95 | + logout: true, |
| 96 | + error: new Error("Session Expired. Please log in again."), |
| 97 | + }; |
| 98 | + } |
| 99 | + |
| 100 | + // For all other errors, just report them without logging out or redirecting |
| 101 | + return {}; |
| 102 | + }, |
| 103 | +}; |
| 104 | + |
| 105 | +export default authProvider; |
0 commit comments