AbuNavsa / QuickJot

0 stars 0 forks source link

Design/Decide local data, database, paid and free #22

Open AbuNavsa opened 1 year ago

AbuNavsa commented 1 year ago

Do I have to create two seperate versions of the same app, one for free and one for paid

One approach is to create a single app with both free and paid versions, and use conditional statements to determine which features are available based on whether the user has purchased the paid version or not. For example, you could use a state variable to keep track of whether the user has purchased the paid version or not, and then enable or disable features based on the value of this variable.

Another approach is to create a single app with all the features available, but limit the number of items that the user can store locally in the free version. You can use a database to store all the items, but only allow the user to access a limited number of items in the free version. You can then unlock the full functionality of the app when the user purchases the paid version.

Ultimately, the approach that you choose will depend on the specifics of your app and your monetization strategy. But the good news is that there are many options available, and you can choose the one that works best for you.

AbuNavsa commented 1 year ago

How would the authentication work if the free one uses a local database such as SQLite and the paid one uses firebase

If your free version of the app uses a local database like SQLite, you can implement authentication within the app by creating a login system that stores the user's login credentials locally on the device. When the user logs in, the app can retrieve the user's data from the local database and display it to them.

For the paid version of the app that uses Firebase, you can use Firebase Authentication to handle the login system. When the user logs in to the paid version of the app, they will be authenticated using Firebase Authentication, which allows the app to access the user's data from the Firebase database.

To ensure that the user's data remains synchronized between the local SQLite database and the Firebase database, you can use a synchronization system that periodically uploads the user's data from the local database to the Firebase database, and downloads any updates from the Firebase database to the local database. You can use Firebase Realtime Database or Firestore for this purpose, which provides real-time synchronization between the local and remote databases.

When the user upgrades from the free version to the paid version, you can prompt them to enter their login credentials for Firebase Authentication. Once the user has been authenticated, the app can download their data from the Firebase database and display it to them.

Overall, this approach allows you to provide both a free and paid version of your app, with authentication handled separately for each version using different databases. By using a synchronization system to keep the data consistent between the local and remote databases, you can ensure that the user's data remains up-to-date regardless of which version of the app they are using.

AbuNavsa commented 1 year ago

How would you securely store the login details for the SQLite version of the authentication?

Storing login credentials securely is an important aspect of any authentication system. In the case of the SQLite version of the authentication, you can use the following best practices to store login details securely:

Hash the password: When a user creates an account or updates their password, you can hash their password using a secure hashing algorithm like bcrypt or scrypt. This ensures that even if the database is compromised, an attacker cannot retrieve the user's plain-text password.

Use a salt: When hashing the password, you should also use a unique salt for each user. This prevents an attacker from using precomputed hashes to crack passwords.

Encrypt the database: To protect against unauthorized access to the database, you can encrypt the database using a strong encryption algorithm. You can use the built-in encryption capabilities of SQLite or a third-party library like SQLCipher.

Use a secure key store: When storing login credentials locally on the device, you can use a secure key store to protect the credentials. On iOS, you can use the Keychain API, while on Android you can use the Android Keystore system.

Use SSL/TLS for communication: When communicating with your backend server, you should use SSL/TLS to encrypt the communication and protect against man-in-the-middle attacks.

By implementing these best practices, you can ensure that the login details for the SQLite version of the authentication are stored securely and protected against unauthorized access.

AbuNavsa commented 1 year ago

How would you do forgot password on a local sqlite authentication database?

To implement a "forgot password" feature for an authentication system that uses a local SQLite database, you can follow these general steps:

Provide a "forgot password" button: Include a "forgot password" button on the login screen that allows users to reset their password.

Collect user information: When the user clicks the "forgot password" button, prompt them to enter their email address or username. This information will be used to identify the user in the database.

Verify user information: Query the SQLite database to find a user with the provided email address or username. If a matching user is found, generate a unique token and store it in the database alongside the user's ID and a timestamp.

Send password reset email: Send an email to the user's email address with a link to a password reset page. The link should include the unique token generated in step 3, which will be used to identify the user on the password reset page.

Handle password reset page: When the user clicks the link in the email, they should be taken to a password reset page. This page should prompt the user to enter a new password and confirm it. When the user submits the form, query the database using the token to find the user's ID and update their password.

Invalidate the token: Once the user has successfully reset their password, invalidate the token in the database to prevent it from being used again.

Notify the user: Notify the user that their password has been reset and provide them with instructions for logging in with their new password.

By following these steps, you can implement a "forgot password" feature for an authentication system that uses a local SQLite database.