diff --git a/README.md b/README.md index 565908e756859..2268a0b194e96 100644 --- a/README.md +++ b/README.md @@ -1,157 +1,105 @@ -

- - AppFlowy
-
- ⭐️ The Open Source Alternative To Notion ⭐️
-

- -

-AppFlowy is the AI workspace where you achieve more without losing control of your data -

- -

- - - -License: AGPL - -

- -

- Website • - Forum • - Discord • - Reddit • - Twitter -

- -

AppFlowy Kanban Board for To-dos

-

AppFlowy Databases for Tasks and Projects

-

AppFlowy Sites for Beautiful documentation

-

AppFlowy AI

-

AppFlowy Templates

- -

-

- Work across devices

-

- Work across devices

-

- Work across devices

- -## User Installation - -- [Download AppFlowy Desktop (macOS, Windows, and Linux)](https://github.com/AppFlowy-IO/AppFlowy/releases) -- Other - channels: [FlatHub](https://flathub.org/apps/io.appflowy.AppFlowy), [Snapcraft](https://snapcraft.io/appflowy), [Sourceforge](https://sourceforge.net/projects/appflowy/) -- Available on - - [App Store](https://apps.apple.com/app/appflowy/id6457261352): iPhone - - [Play Store](https://play.google.com/store/apps/details?id=io.appflowy.appflowy): Android 10 or above; ARMv7 is - not supported -- [Self-hosting AppFlowy](https://appflowy.com/docs/self-host-appflowy-overview) -- [Source](https://docs.appflowy.io/docs/documentation/appflowy/from-source) - -## Built With - -- [Flutter](https://flutter.dev/) - -- [Rust](https://www.rust-lang.org/) - -## Stay Up-to-Date - -

AppFlowy Github - how to star the repo

- -## Getting Started with development - -Please view the [documentation](https://docs.appflowy.io/docs/documentation/appflowy/from-source) for OS specific -development instructions - -## Roadmap - -- [AppFlowy Roadmap ReadMe](https://docs.appflowy.io/docs/appflowy/roadmap) -- [AppFlowy Public Roadmap](https://github.com/orgs/AppFlowy-IO/projects/5/views/12) - -If you'd like to propose a feature, submit a feature -request [here](https://github.com/AppFlowy-IO/AppFlowy/issues/new?assignees=&labels=&template=feature_request.yaml&title=%5BFR%5D+)
-If you'd like to report a bug, submit a bug -report [here](https://github.com/AppFlowy-IO/AppFlowy/issues/new?assignees=&labels=&template=bug_report.yaml&title=%5BBug%5D+) - -## **Releases** - -Please see the [changelog](https://appflowy.com/what-is-new) for more details about a given release. - -## Contributing - -Contributions make the open-source community a fantastic place to learn, inspire, and create. Any contributions you make -are **greatly appreciated**. Please look -at [Contributing to AppFlowy](https://docs.appflowy.io/docs/documentation/software-contributions/contributing-to-appflowy) -for details. - -If your Pull Request is accepted as it fixes a bug, adds functionality, or makes AppFlowy's codebase significantly -easier to use or understand, **Congratulations!** If your administrative and managerial work behind the scenes sustains -the community, **Congratulations!** You are now an official contributor to AppFlowy. - -## Translations 🌎🗺 - -[![translation badge](https://inlang.com/badge?url=github.com/AppFlowy-IO/AppFlowy)](https://inlang.com/editor/github.com/AppFlowy-IO/AppFlowy?ref=badge) - -To add translations, you can manually edit the JSON translation files in `/frontend/resources/translations`, use -the [inlang online editor](https://inlang.com/editor/github.com/AppFlowy-IO/AppFlowy), or -run `npx inlang machine translate` to add missing translations. - -## Join the community to build AppFlowy together - - - - - -## Why Are We Building This? - -Notion has been our favourite project and knowledge management tool in recent years because of its aesthetic appeal and -functionality. Our team uses it daily, and we are on its paid plan. However, as we all know, Notion has its limitations. -These include weak data security and poor compatibility with mobile devices. Likewise, alternative collaborative -workplace management tools also have their constraints. - -The limitations we encountered using these tools and our past work experience with collaborative productivity tools have -led to our firm belief that there is a glass ceiling on what's possible for these tools in the future. This emanates -from the fact that these tools will probably struggle to scale horizontally at some point and be forced to prioritize a -proportion of customers whose needs differ from the rest. While decision-makers want a workplace OS, it is impossible to -come up with a one-size fits all solution in such a fragmented market. - -When a customer's evolving core needs are not satisfied, they either switch to another or build one from the ground up, -in-house. Consequently, they either go under another ceiling or buy an expensive ticket to learn a hard lesson. This is -a requirement for many resources and expertise, building a reliable and easy-to-use collaborative tool, not to mention -the speed and native experience. The same may apply to individual users as well. - -All these restrictions necessitate our mission - to make it possible for anyone to create apps that suit their needs -well. - -- To individuals, we would like to offer Notion's functionality, data security, and cross-platform native experience. -- To enterprises and hackers, AppFlowy is dedicated to offering building blocks and collaboration infra services to - enable you to make apps on your own. Moreover, you have 100% control of your data. You can design and modify AppFlowy - your way, with a single codebase written in Flutter and Rust supporting multiple platforms armed with long-term - maintainability. - -We decided to achieve this mission by upholding the three most fundamental values: - -- Data privacy first -- Reliable native experience -- Community-driven extensibility - -We do not claim to outperform Notion in terms of functionality and design, at least for now. Besides, our priority -doesn't lie in more functionality at the moment. Instead, we would like to cultivate a community to democratize the -knowledge and wheels of making complex workplace management tools while enabling people and businesses to create -beautiful things on their own by equipping them with a versatile toolbox of building blocks. - -## License - -Distributed under the AGPLv3 License. See [`LICENSE.md`](https://github.com/AppFlowy-IO/AppFlowy/blob/main/LICENSE) for -more information. - -## Acknowledgments - -Special thanks to these amazing projects which help power AppFlowy: - -- [cargo-make](https://github.com/sagiegurari/cargo-make) -- [contrib.rocks](https://contrib.rocks) -- [flutter_chat_ui](https://pub.dev/packages/flutter_chat_ui) +// authProvider.ts (or your custom auth provider file) + +import { AuthProvider } from "@refinedev/core"; + +// Define a simple structure for your user identity data +interface UserIdentity { + id: number; + name: string; + email: string; + // Add other fields your app uses +} + +const authProvider: AuthProvider = { + login: async ({ email, password }) => { + // 1. Send credentials to your backend API + // This is a placeholder for your actual API call (e.g., using axios/fetch) + const response = await fetch("YOUR_API_BASE_URL/auth/login", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ email, password }), + }); + + const data = await response.json(); + + if (response.ok && data.token) { + // 2. Store the token on successful login + localStorage.setItem("authToken", data.token); + + // Success response + return { + success: true, + redirectTo: "/", // Redirect to the home page + }; + } + + // Failed login attempt + return { + success: false, + error: new Error(data.message || "Login failed. Check your credentials."), + }; + }, + + logout: async (params) => { + // Clear the token and any user data + localStorage.removeItem("authToken"); + localStorage.removeItem("user"); + + // Success response + return { + success: true, + redirectTo: "/login", // Always redirect to the login page + }; + }, + + checkAuth: async (params) => { + const token = localStorage.getItem("authToken"); + + if (token) { + // User is authenticated + return { + authenticated: true, + }; + } + + // User is not authenticated, redirect to login + return { + authenticated: false, + redirectTo: "/login", + }; + }, + + getIdentity: async () => { + const user = localStorage.getItem("user"); + + if (user) { + // Return parsed user identity + return JSON.parse(user) as UserIdentity; + } + + // If identity is not found, return null or throw error if session is strictly required + return null; + }, + + // 🌟 FIX FOR THE INFINITE LOOP BUG (Issue #6997) 🌟 + onError: async (error) => { + // Ensure we can extract a status code from the error object + const status = (error as any)?.statusCode || (error as any)?.response?.status; + + // Check for Unauthorized (401) or Forbidden (403) status codes + if (status === 401 || status === 403) { + // The crucial fix is returning `{ logout: true }`. + // This instructs Refine's core to call the 'logout' method, + // which handles clearing the session and redirecting, preventing the loop. + return { + logout: true, + error: new Error("Session Expired. Please log in again."), + }; + } + + // For all other errors, just report them without logging out or redirecting + return {}; + }, +}; + +export default authProvider; \ No newline at end of file