Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • GfG 160: Daily DSA
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • System Design Tutorial
  • What is System Design
  • System Design Life Cycle
  • High Level Design HLD
  • Low Level Design LLD
  • Design Patterns
  • UML Diagrams
  • System Design Interview Guide
  • Scalability
  • Databases
Open In App
Next Article:
Designing Authentication System | System Design
Next article icon

Designing Authentication System | System Design

Last Updated : 31 Jan, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Keeping your important digital information safe is like building a strong foundation, and the key to that is a good security system. This article will help you understand how to make a robust security system step by step. We'll start with figuring out what you want to protect and what you want to achieve. Then, we'll talk about the detailed design aspects, like how the system works at both the small and big levels, the structure of the database, using smaller specialized services, and making sure the system can handle more load without slowing down.

designin-authentication-system-(1)

Important Topics for the Authentication System Design

  • Requirements Gathering for Authentication System Design
  • Capacity Estimation for Authentication System Design
  • Use Case Diagram for Authentication System Design
  • Low-Level Design(LLD) for Authentication System Design
  • High-Level Design(HLD) for Authentication System Design
  • Database Design for Authentication System Design
  • Microservices used for Authentication System Design
  • API Used for Authentication System Design
  • API Code Implementation for Authentication System
  • Scalability for Authentication System Design

1. Requirements Gathering for Authentication System Design

Functional Requirements for Authentication System Design

  • User Registration: Allow users to register by providing necessary information.
  • Login: Authenticate users based on their credentials.
  • Multi-Factor Authentication (MFA): Implement a robust MFA system.
  • Password Recovery: Provide a secure process for users to recover their passwords.
  • Session Management: Efficiently manage user sessions to ensure security.
  • Access Control: Define roles and permissions for different user types.
  • Audit Trail: Maintain detailed logs of authentication events for auditing.

Non-Functional Requirements for Authentication System Design

  • Security: Prioritize data security through encryption, secure storage, and secure communication.
  • Scalability: Design the system to handle a growing number of users and transactions.
  • Performance: Ensure low latency and quick response times.
  • Reliability: Minimize system downtime and ensure high availability.
  • Usability: Develop an intuitive user interface for a seamless experience.

2. Capacity Estimation for Authentication System Design

You can estimate the system capacity by analyzing certain data like traffic, number of user coming on site. Here is the simplified calculation given:

2.1. Traffic Estimation

Assumption - Traffic is 100,000 vistors per month
Each authentication request is assumed to take 1 second for simplification.
Traffic per second = 100000/30*24*60*60= 0.038
Authentication Requests per Second = Traffic per Second
Authentication Requests per Second = 0.038

2.2. Storage Estimation

Assumption - Each authentication request is assumed to take approx 2kb/file size
Monthly Storage = Monthly Visitors × Average Authentication request/User Data Size
Monthly Storage=100,000×2 KB
Monthly Storage = 200,000KB or 195.31 MB(approx)

3. Use Case Diagram for Authentication System Design

Use-Case-Diagram

The web user initiates the interaction by logging in or registering. After successful authentication, the user can perform actions like viewing transaction history, checking balance, or processing bill payments. The user may choose to log out when the interaction is complete.

  • The system server oversees the entire interaction, coordinating the authentication process and managing user sessions. It facilitates the user's selection of services and handles the logout process.
  • The bank actor interacts with the system to update the user's balance based on transactions or activities initiated by the web user.
  • The registered user initiates the login process, providing valid credentials for authentication. Upon successful authentication, the user gains access to various services offered by the system.
  • The new user initiates the registration process, providing necessary information to create a new account.After successful registration, the user can proceed to log in and access the system.
  • The system authentication component manages the authentication process for both registered and new users. It verifies user credentials during login and facilitates the registration process for new users.

4. Low-Level Design(LLD) for Authentication System Design

Low-level design majorly focuses on component and module of the system. It focuses on the actual implementation details, algorithms, and data structures. Key components in the low-level design of an authentication system are described below:

Low-Level-Design-(1)

Let's understand the main components of Low Level Design:

1. Authentication Server:

  • Handling Refresh Token
    • Client sends a request for a refresh token.
    • Authentication server validates the client's identity.
    • If valid, a new refresh token is generated and sent to the client.
  • Handling Access Token
    • Client sends authentication credentials for access token.
    • Authentication server verifies the credentials.
    • If valid, an access token is generated and sent to the client.

2. Client:

  • Connecting to Authentication Server
    • Client establishes a connection to the authentication server.
    • It utilizes the refresh token or authentication credentials to interact.
  • Connecting to Resource Server
    • Client establishes a connection to the resource server.
    • It uses the access token to request protected resources.
  • Using Refresh Token
    • Client sends a request for a new access token using the refresh token.
    • Authentication server validates the refresh token.
    • If valid, a new access token is issued to the client.
  • Using Access Token
    • Client includes the access token in requests to the resource server.
    • Resource server validates the access token.
    • If valid, it grants access to the requested protected resource.

3. Resource Server:

  • Resource server validates the access token.
  • If valid, it provides access to the requested resource.
  • Client sends a request with an access token to access a protected resource.

5. High-Level Design(HLD) for Authentication System Design

High-level design provides a indepth overview of the overall system architecture, which describes the interaction between major components. It mainly focus on the system's structure, major modules, and the flow of data. Key components in the high-level design of an authentication system are described as follow:

High-Level-Design

Let's understand High Level Design of the Authentication System :

1. User Registration Section:

  • Data Acquisition
    • User provides registration information.
    • System acquires and validates user data.
  • Pre-processing and Feature Extracting
    • Raw user data undergoes pre-processing for normalization and cleaning.
    • Features are extracted for use in the registration process.

2. Login Section:

  • Data Acquisition
    • User provides login credentials.
    • System acquires and validates user login data.
  • Pre-processing and Feature Extracting
    • Raw login data undergoes pre-processing for normalization.
    • Features are extracted for authentication.

3. Real-Time Authentication Section:

What is a model?
A "model" refers to a representation or set of parameters that characterize a specific user's behavior or characteristics. These models are generated based on the registered user data and are stored in a database for real-time use during the authentication process.

  • Model Generation
    • Models are generated based on registered user data.
    • Model parameters are stored for real-time use.
  • Model Database
    • The database stores generated user models.
  • Classifier (if True)
    • Classifier determines if the user is legitimate.
    • If classified as true, user is authenticated.
    • System welcomes and grants access to the authenticated user.
  • Classifier (if False)
    • If classified as false (imposter), the system initiates imposter rejection.
    • Appropriate actions are taken to prevent unauthorized access.

6. Database Design for Authentication System Design

Database design for authentication system:

6.1. User Table

The User Table stores user data with the following fields:

  • user_id (PK): Unique identifier for each user.
  • username: User's username for authentication.
  • email: User's email address for communication.
  • password: Encrypted password for user authentication.
  • created_at: Timestamp indicating when the user account was created.

6.2. Credentials Table

The Credentials Table stores login credentials, including hashed passwords, with the following fields:

  • credential_id (PK): Unique identifier for each credential.
  • user_id (FK): Foreign key referencing the User Table.
  • password_hash: Hashed password for user authentication.
  • last_login: Timestamp indicating the user's last login.

6.3. Password Table

Password table are used to store passwords set by user. It includes field like

  • password_id (PK): Unique identifier for each password entry.
  • user_id (FK): Foreign key referencing the User Table.
  • password_hash: Hashed password for user authentication.

6.4. PasswordResetRequests Table

is used to store information related to password reset requests initiated by users. It include field like

  • request_id (PK): Unique identifier for each password reset request.
  • user_id (FK): Foreign key referencing the User Table.
  • token_value: Value of the token for the password reset.
  • expiration_time: Timestamp indicating when the password reset token expires.

6.5. Session Table

The Session Table tracks user sessions with the following fields:

  • session_id (PK): Unique identifier for each session.
  • user_id (FK): Foreign key referencing the User Table.
  • login_time: Timestamp indicating the session login time.
  • last_activity: Timestamp indicating the session's last activity.

6.6. Token Table

The Token Table stores information about user tokens with the following fields:

  • token_id (PK): Unique identifier for each token.
  • user_id (FK): Foreign key referencing the User Table.
  • token_value: Value of the token for authentication.
  • expiration_time: Timestamp indicating when the token expires.

7. Microservices used for Authentication System Design

7.1. User Management Microservice:

This microservice handles tasks related to user registration, profile management, and user data storage. It includes functionalities such as creating new user accounts, updating user information, and handling account deletion requests.

API Endpoints:

  • /register: Create a new user account.
  • /update/:userId: Update user information.
  • /delete/:userId: Delete a user account.

7.2. Authentication Microservice:

Responsible for verifying user credentials during the login process, implementing multi-factor authentication (MFA), and generating authentication tokens. This microservice ensures the security of the authentication process.

API Endpoints:

  • /login: Authenticate user credentials.
  • /logout: End user session and revoke authentication tokens.
  • /mfa/:userId: Handle multi-factor authentication.

7.3. Authorization Microservice:

Manages access control and permissions based on user roles. This microservice ensures that authenticated users have the appropriate permissions to access specific resources or perform certain actions.

API Endpoints:

  • /grant/:userId/:permission: Grant specific permissions to a user.
  • /revoke/:userId/:permission: Revoke permissions from a user.
  • /check/:userId/:resource: Check user's access to a specific resource.

7.4. Session Management Microservice:

Handles the creation, maintenance, and termination of user sessions. This microservice ensures secure session handling and can implement features like session timeouts and token revocation.

API Endpoints:

  • /create/:userId: Create a new user session.
  • /expire/:sessionId: Expire a user session.
  • /validate/:sessionId: Validate an active user session.

8. API Used for Authentication System Design

APIs (Application Programming Interfaces) serve as the communication channels between different microservices and external components. The APIs define the rules and protocols for how different software components should interact. In the context of an authentication system, various APIs are used for seamless communication between microservices:

8.1. RESTful APIs:

RESTful APIs are commonly used for communication between microservices due to their simplicity and statelessness. Each microservice exposes a set of RESTful endpoints, allowing other services to make HTTP requests to perform specific actions.

8.2. Token-Based APIs:

For secure communication and data exchange, token-based APIs, such as JSON Web Tokens (JWT), are often employed. JWTs can be used to carry authentication information securely between microservices without the need to repeatedly verify credentials.

8.3. OpenID Connect and OAuth 2.0:

OpenID Connect and OAuth 2.0 are widely adopted authentication and authorization protocols. They define a set of rules for secure and standardized user authentication, allowing third-party applications to access user data without exposing sensitive credentials.

8.4. GraphQL:

GraphQL is an alternative to RESTful APIs that allows clients to request only the specific data they need. In the context of an authentication system, GraphQL can be used to efficiently query user information and manage authentication-related operations.

9. API Code Implementation for Authentication System

9.1. User Registration API (POST):

Endpoint: /api/user/register

Description: Allows users to securely create their accounts.

Request
{
  "username": "example_user",
  "email": "user@example.com",
  "password": "securepassword123"
}
Response
{
  "status": "success",
  "message": "User registration successful"
}

9.2. Authentication API (POST):

Endpoint: /api/user/authenticate

Description: Initiates user authentication.

Request
{
  "username": "example_user",
  "password": "securepassword123"
}
Response
{
  "status": "success",
  "message": "User authentication successful",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

9.3. Access Protected Resource API (GET):

Endpoint: /api/resource/access

Description: Allows access to a protected resource.

Request
GET /api/resource/access
Host: your-authentication-api.com
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Response
{
  "status": "success",
  "message": "Resource accessed successfully",
  "data": "This is a protected resource content."
}

9.4. Update Password API (PUT):

Endpoint: /api/user/update-password

Description: Updates the user's password.

Request
{
  "user_id": "12345",
  "current_password": "oldpassword",
  "new_password": "newsecurepassword456"
}
Response
{
  "status": "success",
  "message": "Password updated successfully"
}

10. Scalability for Authentication System Design

Consideration for scalability is crucial to ensure the system can handle increased load. Key strategies for scalability in an authentication system include:

10.1. Load Balancing

Implement load balancing mechanisms to distribute incoming authentication requests evenly across multiple servers. This ensures optimal resource utilization and prevents any single point of failure.

10.2. Horizontal Scaling

Design the system to scale horizontally, allowing the addition of more servers or instances to accommodate growing user traffic.

10.3. Caching

Utilize caching mechanisms for frequently accessed data, such as user credentials or session information, to reduce the load on the database and improve response times.

10.4. Elasticity

Implement auto-scaling features to dynamically adjust resources based on demand. This ensures efficient resource utilization during peak periods and cost-effectiveness during low traffic times.

11. Conclusion

Designing an authentication system is a critical aspect of any secure application. Balancing usability and security, understanding the importance of various components, and staying vigilant against emerging threats are key to building a resilient authentication system.


Next Article
Designing Authentication System | System Design

A

aaaryanaguae5
Improve
Article Tags :
  • Geeks Premier League
  • System Design
  • Geeks Premier League 2023

Similar Reads

    System Analysis | System Design
    In the areas of science, information technology, and knowledge, the difficulty of systems is of much importance. As systems became more complicated, the traditional method of problem-solving became inefficient. System analysis is to examine a business problem, identify its objectives and requirement
    6 min read
    Resilient System - System Design
    Imagine you're building a castle out of blocks. If you design it so that removing one block doesn't make the whole castle collapse, you've made something resilient. hen we talk about creating a resilient system, we're essentially doing the same thing but with computer systems. These systems are desi
    10 min read
    What is Systems Design - Learn System Design
    System Design is the process of defining the architecture, components, modules, interfaces, and data for a system to satisfy specified requirements. It involves translating user requirements into a detailed blueprint that guides the implementation phase. The goal is to create a well-organized and ef
    11 min read
    What is the Correlation Between System Design and Design Patterns?
    System design and design patterns are closely related concepts in software engineering, with design patterns serving as reusable solutions to common design problems encountered during system design. System design and design patterns are interrelated concepts that work together to create robust and w
    11 min read
    Differences between System Analysis and System Design
    System Analysis and System Design are two stages of the software development life cycle. System Analysis is a process of collecting and analyzing the requirements of the system whereas System Design is a process of creating a design for the system to meet the requirements. Both are important stages
    4 min read
    Exposing 13 Myths About System Design
    In this article, we will explore common misconceptions people have about designing systems. Think of systems like the gears in a machine they're the organized way things work together. However, there are some myths floating around about how these systems should be designed. By eliminating these myth
    10 min read
    System Design vs. Software Design
    System Design and Software Design are two important concepts in the creation of robust and effective technological solutions. While often used interchangeably, they represent distinct disciplines with unique focuses and methodologies. System Design encompasses the architecture and integration of har
    8 min read
    Case Studies in System Design
    System design case studies provide important insights into the planning and construction of real-world systems. You will discover helpful solutions to typical problems like scalability, dependability, and performance by studying these scenarios. This article highlights design choices, trade-offs, an
    3 min read
    Design Restaurant Management System | System Design
    In the modern restaurant industry, delivering exceptional dining experiences requires more than just good cuisine. Restaurant Management Systems have emerged as the secret ingredient for efficient operations and customer satisfaction. In this article, we are going to design a restaurant management s
    15 min read
    System Design Life Cycle | SDLC (Design)
    System Design Life Cycle is defined as the complete journey of a System from planning to deployment. The System Design Life Cycle is divided into 7 Phases or Stages, which are:1. Planning Stage 2. Feasibility Study Stage 3. System Design Stage 4. Implementation Stage 5. Testing Stage 6. Deployment S
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

'); // $('.spinner-loading-overlay').show(); let script = document.createElement('script'); script.src = 'https://assets.geeksforgeeks.org/v2/editor-prod/static/js/bundle.min.js'; script.defer = true document.head.appendChild(script); script.onload = function() { suggestionModalEditor() //to add editor in suggestion modal if(loginData && loginData.premiumConsent){ personalNoteEditor() //to load editor in personal note } } script.onerror = function() { if($('.editorError').length){ $('.editorError').remove(); } var messageDiv = $('
').text('Editor not loaded due to some issues'); $('#suggestion-section-textarea').append(messageDiv); $('.suggest-bottom-btn').hide(); $('.suggestion-section').hide(); editorLoaded = false; } }); //suggestion modal editor function suggestionModalEditor(){ // editor params const params = { data: undefined, plugins: ["BOLD", "ITALIC", "UNDERLINE", "PREBLOCK"], } // loading editor try { suggestEditorInstance = new GFGEditorWrapper("suggestion-section-textarea", params, { appNode: true }) suggestEditorInstance._createEditor("") $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = true; } catch (error) { $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = false; } } //personal note editor function personalNoteEditor(){ // editor params const params = { data: undefined, plugins: ["UNDO", "REDO", "BOLD", "ITALIC", "NUMBERED_LIST", "BULLET_LIST", "TEXTALIGNMENTDROPDOWN"], placeholderText: "Description to be......", } // loading editor try { let notesEditorInstance = new GFGEditorWrapper("pn-editor", params, { appNode: true }) notesEditorInstance._createEditor(loginData&&loginData.user_personal_note?loginData.user_personal_note:"") $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = true; } catch (error) { $('.spinner-loading-overlay:eq(0)').remove(); editorLoaded = false; } } var lockedCasesHtml = `You can suggest the changes for now and it will be under 'My Suggestions' Tab on Write.

You will be notified via email once the article is available for improvement. Thank you for your valuable feedback!`; var badgesRequiredHtml = `It seems that you do not meet the eligibility criteria to create improvements for this article, as only users who have earned specific badges are permitted to do so.

However, you can still create improvements through the Pick for Improvement section.`; jQuery('.improve-header-sec-child').on('click', function(){ jQuery('.improve-modal--overlay').hide(); $('.improve-modal--suggestion').hide(); jQuery('#suggestion-modal-alert').hide(); }); $('.suggest-change_wrapper, .locked-status--impove-modal .improve-bottom-btn').on('click',function(){ // when suggest changes option is clicked $('.ContentEditable__root').text(""); $('.suggest-bottom-btn').html("Suggest changes"); $('.thank-you-message').css("display","none"); $('.improve-modal--improvement').hide(); $('.improve-modal--suggestion').show(); $('#suggestion-section-textarea').show(); jQuery('#suggestion-modal-alert').hide(); if(suggestEditorInstance !== null){ suggestEditorInstance.setEditorValue(""); } $('.suggestion-section').css('display', 'block'); jQuery('.suggest-bottom-btn').css("display","block"); }); $('.create-improvement_wrapper').on('click',function(){ // when create improvement option clicked then improvement reason will be shown if(loginData && loginData.isLoggedIn) { $('body').append('
'); $('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.unlocked-status--improve-modal-content').css("display","none"); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { showErrorMessage(e.responseJSON,e.status) }, }); } else { if(loginData && !loginData.isLoggedIn) { $('.improve-modal--overlay').hide(); if ($('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { $('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } } }); $('.left-arrow-icon_wrapper').on('click',function(){ if($('.improve-modal--suggestion').is(":visible")) $('.improve-modal--suggestion').hide(); else{ } $('.improve-modal--improvement').show(); }); const showErrorMessage = (result,statusCode) => { if(!result) return; $('.spinner-loading-overlay:eq(0)').remove(); if(statusCode == 403) { $('.improve-modal--improve-content.error-message').html(result.message); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); $('.locked-status--impove-modal').css("display","block"); $('.unlocked-status--improve-modal-content').css("display","none"); $('.improve-modal--improvement').attr("status","locked"); return; } } function suggestionCall() { var editorValue = suggestEditorInstance.getValue(); var suggest_val = $(".ContentEditable__root").find("[data-lexical-text='true']").map(function() { return $(this).text().trim(); }).get().join(' '); suggest_val = suggest_val.replace(/\s+/g, ' ').trim(); var array_String= suggest_val.split(" ") //array of words var gCaptchaToken = $("#g-recaptcha-response-suggestion-form").val(); var error_msg = false; if(suggest_val != "" && array_String.length >=4){ if(editorValue.length <= 2000){ var payload = { "gfg_post_id" : `${post_id}`, "suggestion" : `${editorValue}`, } if(!loginData || !loginData.isLoggedIn) // User is not logged in payload["g-recaptcha-token"] = gCaptchaToken jQuery.ajax({ type:'post', url: "https://apiwrite.geeksforgeeks.org/suggestions/auth/create/", xhrFields: { withCredentials: true }, crossDomain: true, contentType:'application/json', data: JSON.stringify(payload), success:function(data) { if(!loginData || !loginData.isLoggedIn) { grecaptcha.reset(); } jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('.suggest-bottom-btn').css("display","none"); $('#suggestion-section-textarea').hide() $('.thank-you-message').css('display', 'flex'); $('.suggestion-section').css('display', 'none'); jQuery('#suggestion-modal-alert').hide(); }, error:function(data) { if(!loginData || !loginData.isLoggedIn) { grecaptcha.reset(); } jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Something went wrong."); jQuery('#suggestion-modal-alert').show(); error_msg = true; } }); } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Minimum 4 Words and Maximum Words limit is 1000."); jQuery('#suggestion-modal-alert').show(); jQuery('.ContentEditable__root').focus(); error_msg = true; } } else{ jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Enter atleast four words !"); jQuery('#suggestion-modal-alert').show(); jQuery('.ContentEditable__root').focus(); error_msg = true; } if(error_msg){ setTimeout(() => { jQuery('.ContentEditable__root').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } } document.querySelector('.suggest-bottom-btn').addEventListener('click', function(){ jQuery('body').append('
'); jQuery('.spinner-loading-overlay').show(); if(loginData && loginData.isLoggedIn) { suggestionCall(); return; } // script for grecaptcha loaded in loginmodal.html and call function to set the token setGoogleRecaptcha(); }); $('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked $('body').append('
'); $('.spinner-loading-overlay').show(); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id }), success:function(result) { $('.spinner-loading-overlay:eq(0)').remove(); $('.improve-modal--overlay').hide(); $('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `${result.id}` + '/', '_blank'); $('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { showErrorMessage(e.responseJSON,e.status); }, }); });
"For an ad-free experience and exclusive features, subscribe to our Premium Plan!"
Continue without supporting
`; $('body').append(adBlockerModal); $('body').addClass('body-for-ad-blocker'); const modal = document.getElementById("adBlockerModal"); modal.style.display = "block"; } function handleAdBlockerClick(type){ if(type == 'disabled'){ window.location.reload(); } else if(type == 'info'){ document.getElementById("ad-blocker-div").style.display = "none"; document.getElementById("ad-blocker-info-div").style.display = "flex"; handleAdBlockerIconClick(0); } } var lastSelected= null; //Mapping of name and video URL with the index. const adBlockerVideoMap = [ ['Ad Block Plus','https://media.geeksforgeeks.org/auth-dashboard-uploads/abp-blocker-min.mp4'], ['Ad Block','https://media.geeksforgeeks.org/auth-dashboard-uploads/Ad-block-min.mp4'], ['uBlock Origin','https://media.geeksforgeeks.org/auth-dashboard-uploads/ub-blocke-min.mp4'], ['uBlock','https://media.geeksforgeeks.org/auth-dashboard-uploads/U-blocker-min.mp4'], ] function handleAdBlockerIconClick(currSelected){ const videocontainer = document.getElementById('ad-blocker-info-div-gif'); const videosource = document.getElementById('ad-blocker-info-div-gif-src'); if(lastSelected != null){ document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.backgroundColor = "white"; document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.borderColor = "#D6D6D6"; } document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.backgroundColor = "#D9D9D9"; document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.borderColor = "#848484"; document.getElementById('ad-blocker-info-div-name-span').innerHTML = adBlockerVideoMap[currSelected][0] videocontainer.pause(); videosource.setAttribute('src', adBlockerVideoMap[currSelected][1]); videocontainer.load(); videocontainer.play(); lastSelected = currSelected; }

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences