hiyaryan / the-cdj

The Cognitive Distortion Journal (CDJ) is a smart journaling tool that helps remedy distorted thinking. It can feel impossible to follow the CBT technique of labeling distorted thinking and finding alternative modes of thought (i.e. reframing) while cognitive distortions are occurring. The CDJ does that work for you. -- The CDJ is in beta testing!!
https://thecdj.app
3 stars 0 forks source link

Enhanced beta access control and error handling in access controllers. #88

Closed hiyaryan closed 7 months ago

hiyaryan commented 7 months ago

Enhanced Beta Access Control and Error Handling in Access Controllers

This commit introduces significant improvements and fixes in the backend access controllers, with a focus on beta access management and user authentication error handling.

Detailed Changes

  1. login Function:

    • Introduced async functionality to the passport.authenticate callback for enhanced asynchronous processing.
    • Implemented detailed checks and user-friendly responses for cases where users lack beta access or have unverified email addresses.
    • Updated status codes and error messages for improved specificity and clarity.
  2. forgotPassword Function:

    • Added logic to address scenarios where beta access status is undefined, indicating pending decisions.
    • Incorporated measures to prevent spamming of the email server by users repeatedly attempting password recovery without beta access.
    • Implemented a new feature to alert administrators about potential misuse of the forgot password feature by users without beta access.
  3. betaApproval and betaDenial Functions:

    • Eliminated the redundant betaAccess: false conditions from User.findOne queries to streamline the code.
    • Revised the modification of user properties to offer clearer management of beta access status.
  4. requestBetaAccess Function in Access.js Middleware:

    • Enhanced the logic for creating new users and updating existing users' records for beta access requests.
    • Introduced thorough checks and tailored responses depending on a user's beta access and email verification status.
    • Updated error handling and messaging to guide users more effectively through the beta access request process.
  5. Updates in User.js Model:

    • Changed the default value of the betaAccess property from false to undefined, signifying unreviewed beta access requests.
    • Removed an unnecessary save call in the generateEmailVerificationToken method for efficiency.
    • Updated email subject lines and body content in various methods to reflect the new approach to beta access management.
  6. Email Content and Variable Naming:

    • Revised email templates to provide clearer instructions and information related to beta access and account verification.
    • Renamed variables and methods (e.g., sendBetaRequestConfirmationEmail to sendBetaAccessVerificationEmail) for better readability and understanding of their functionality.

Summary

Overall, these enhancements not only make the system more robust and secure but also significantly improve user experience by providing clearer communication and more intuitive responses related to beta access and authentication processes.