<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Hasnain01-hub</title>
    <description>The latest articles on Forem by Hasnain01-hub (@hasnain01hub).</description>
    <link>https://forem.com/hasnain01hub</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F528264%2Fd84a6816-68c8-4606-a941-c2895918fe7d.jpeg</url>
      <title>Forem: Hasnain01-hub</title>
      <link>https://forem.com/hasnain01hub</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hasnain01hub"/>
    <language>en</language>
    <item>
      <title>Sentiment Analysis &amp; Course Recommendation using Web Scraping</title>
      <dc:creator>Hasnain01-hub</dc:creator>
      <pubDate>Sun, 22 Dec 2024 05:40:54 +0000</pubDate>
      <link>https://forem.com/hasnain01hub/sentiment-analysis-course-recommendation-using-web-scraping-1pc6</link>
      <guid>https://forem.com/hasnain01hub/sentiment-analysis-course-recommendation-using-web-scraping-1pc6</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/brightdata"&gt;Bright Data Web Scraping Challenge&lt;/a&gt;: Most Creative Use of Web Data for AI Models&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;The "Sentiment Analysis for Course Recommendation" project leverages web scraping and a robust machine learning model, featuring a Random Forest Classifier trained on the Coursera dataset, to assess courses based on user comments and sentiments, offering a more nuanced rating system beyond conventional star ratings. Users simply input the URL of a course they wish to evaluate, and the system extracts and classifies comments as positive, negative, or neutral. The resultant course rating is computed from these sentiments, facilitating informed decision-making for prospective learners. Additionally, the application offers course comparison functionality, allowing users to evaluate courses based on diverse criteria. This innovative approach, built with Python, Flask, and the YouTube API, empowers individuals to make education choices tailored to their specific needs and preferences, enhancing the online learning experience.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffoa20vxomr82gcvsn4vb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffoa20vxomr82gcvsn4vb.png" alt="flowchart" width="800" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/dpwustwce/image/upload/v1734845594/qjlclhnfikf3lja9qk6t.gif" rel="noopener noreferrer"&gt;https://res.cloudinary.com/dpwustwce/image/upload/v1734845594/qjlclhnfikf3lja9qk6t.gif&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F24snxyfoqpkuksps2hj6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F24snxyfoqpkuksps2hj6.png" alt="Image description" width="800" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Used Bright Data
&lt;/h2&gt;

&lt;p&gt;Collect real-time user reviews and comments from course platforms like Coursera. Preprocess the data to remove noise, label sentiments (positive, negative, neutral), and structure it into a training-ready format. Fine-tune a sentiment analysis model like Random Forest or a transformer-based model, integrating it into a Flask-based application for personalized course recommendations and comparisons.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>brightdatachallenge</category>
      <category>ai</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Optimizing AI Conversations: A Deep Dive into Semantic Search and Multi-Modal Input</title>
      <dc:creator>Hasnain01-hub</dc:creator>
      <pubDate>Sat, 05 Oct 2024 08:05:29 +0000</pubDate>
      <link>https://forem.com/hasnain01hub/ai-chat-assistant-pinata-challenge-34m9</link>
      <guid>https://forem.com/hasnain01hub/ai-chat-assistant-pinata-challenge-34m9</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/pinata"&gt;The Pinata Challenge &lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;I developed an AI Chat Assistant platform that leverages advanced semantic search to analyze and retrieve relevant data from a diverse content. The platform intelligently processes user prompts through the LangGraph tool, which determines when to invoke the RAG (retrieval-augmented generation) tool only when necessary, optimizing performance. This ensures that relevant references are efficiently retrieved to enhance the accuracy and relevance of the language model's responses.&lt;/p&gt;

&lt;p&gt;The system supports multiple input formats, including images, YouTube links, and PDFs. For videos, it retrieves metadata via the YouTube API and generates concise summaries using a large language model (LLM). Similarly, it summarizes content from images, providing a comprehensive and versatile user experience across different media types.&lt;/p&gt;

&lt;p&gt;Additionally, the platform integrates Stable Diffusion to generate images based on textual prompts. These generated images are stored in Pinata (IPFS). The platform also maintains a complete chat history, ensuring smooth continuity in conversations and allowing users to reference previous interactions effortlessly.&lt;/p&gt;

&lt;p&gt;LangGraph Flow:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6u68rgzllqqz5kw5yag7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6u68rgzllqqz5kw5yag7.png" alt="Agent Flow" width="800" height="744"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Advanced Semantic Search&lt;/strong&gt;: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Efficiently analyzes and retrieves relevant data from a vector store.&lt;/li&gt;
&lt;li&gt;Utilizes the LangGraph tool to optimize workflows by invoking the RAG tool only when necessary.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Multi-Format Input Support&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Processes images, YouTube links, PDFs, and text files.&lt;/li&gt;
&lt;li&gt;Retrieves video metadata via the YouTube API and generates concise summaries using LLMs.&lt;/li&gt;
&lt;li&gt;Summarizes content from images for seamless multi-media analysis.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Image Generation&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Integrates Stable Diffusion to generate images based on user-provided text prompts.&lt;/li&gt;
&lt;li&gt;Stores generated images using Pinata (IPFS) for decentralized access.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Comprehensive Chat History&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Allows users to select which chats to store and easily reference previous interactions.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Optimized Performance&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LangGraph tool ensures that RAG is only called when necessary, enhancing response relevance and efficiency.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Demo Video:&lt;a href="https://www.youtube.com/watch?v=B-6wPgsLPEM" rel="noopener noreferrer"&gt; Link&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  My Code
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Hasnain01-hub" rel="noopener noreferrer"&gt;
        Hasnain01-hub
      &lt;/a&gt; / &lt;a href="https://github.com/Hasnain01-hub/ai_chat_assistant" rel="noopener noreferrer"&gt;
        ai_chat_assistant
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;AI Chat Assistant&lt;/h1&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Description&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;This platform utilizes advanced semantic search algorithms to analyze and retrieve relevant data from this diverse content repository. After processing the input prompt, the system performs a semantic search to fetch pertinent content, which is then used as references for the language model to enhance the accuracy and relevance of its outputs.&lt;/p&gt;
&lt;p&gt;The platform is designed to handle inputs across a diverse formats including images, YouTube links, and pdf files. For videos, it fetches metadata through the YouTube API, which is then effectively summarized using a LLM to provide concise and relevant content overviews. Similarly, the system is equipped to summarize content from images, ensuring a comprehensive and versatile user experience that accommodates various types of media.&lt;/p&gt;
&lt;p&gt;Additionally, the platform incorporates the capability to generate images using the Stable Diffusion algorithm, further enriching the user interaction experience by providing visual content generation based on textual prompts…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Hasnain01-hub/ai_chat_assistant" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  More Details
&lt;/h2&gt;

&lt;p&gt;This platform integrates Stable Diffusion to generate images based on user textual prompts. The generated images are stored in Pinata (IPFS), which also maintains the chat history, it utilizes CDN for efficient access to the images.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fergltzn1i97czfxnmrmi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fergltzn1i97czfxnmrmi.png" alt="Chat History" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TechStack used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;NextJS&lt;/li&gt;
&lt;li&gt;Langchain&lt;/li&gt;
&lt;li&gt;LangGraph&lt;/li&gt;
&lt;li&gt;Pinata&lt;/li&gt;
&lt;li&gt;Huggingface API&lt;/li&gt;
&lt;li&gt;Azure OpenAI LLM&lt;/li&gt;
&lt;li&gt;Pinecone&lt;/li&gt;
&lt;li&gt;Firebase&lt;/li&gt;
&lt;li&gt;Redux&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devchallenge</category>
      <category>pinatachallenge</category>
      <category>webdev</category>
      <category>api</category>
    </item>
    <item>
      <title>Firebase VS PocketBase VS Appwrite</title>
      <dc:creator>Hasnain01-hub</dc:creator>
      <pubDate>Mon, 05 Jun 2023 10:12:18 +0000</pubDate>
      <link>https://forem.com/hasnain01hub/firebase-vs-pocketbase-vs-appwrite-5k0</link>
      <guid>https://forem.com/hasnain01hub/firebase-vs-pocketbase-vs-appwrite-5k0</guid>
      <description>&lt;p&gt;What is Database?&lt;br&gt;
&lt;strong&gt;(Database)=&lt;/strong&gt; &lt;br&gt;
A database is a structured and organised collection of information that is specifically designed to efficiently store and retrieve data related to an application. It provides a reliable and centralized storage solution where application-specific data, such as user information, product details, or transaction records, can be securely stored and accessed when needed. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Firebase&lt;/strong&gt;&lt;br&gt;
Firebase is a comprehensive mobile and web development platform provided by Google. It offers a variety of tools and services that enable developers to build high-quality applications quickly and efficiently.  It uses NoSQL for the database for the storage of data. Firebase provides features such as real-time database, authentication, cloud storage, hosting, and analytics, among others, simplifying the development process and enhancing application functionality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs5r3sk424p81fwi2sndf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs5r3sk424p81fwi2sndf.png" alt="Firebase"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PocketBase&lt;/strong&gt;&lt;br&gt;
PocketBase is an open-source Backend-as-a-service (BaaS). It offers all necessary needed features like authentication, file storage, realtime database and web dashboard.&lt;br&gt;
PocketBase uses an SQLite Database behind the scene and is written in Go. They offer an awesome JavaScript/Go SDK. You are able to configure permission rules, OAuth2, external file storage (S3) and mail (SMTP).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv2o95wowra0nzci68zlq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv2o95wowra0nzci68zlq.png" alt="PocketBase"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AppWrite&lt;/strong&gt;&lt;br&gt;
AppWrite is an open-source backend server and API platform that simplifies the development of web and mobile applications. It provides a comprehensive set of features and services that handle common backend tasks, allowing developers to focus on building frontend experiences. With AppWrite, developers can quickly set up user authentication, manage databases, handle file storage, and utilize real-time event handling, among other functionalities. It is designed to be flexible, secure, and scalable, making it an ideal choice for developers looking to streamline their backend development process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7tjb4ahy6l3w4w05cazq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7tjb4ahy6l3w4w05cazq.png" alt="Appwrite"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Comparison between these three platform&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgmd792li9aqgaa9l7mdc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgmd792li9aqgaa9l7mdc.png" alt="Comprasion"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>discuss</category>
      <category>opensource</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Multi-Factor(MFA) Authentication in React JS using firebase</title>
      <dc:creator>Hasnain01-hub</dc:creator>
      <pubDate>Sun, 01 Jan 2023 18:16:15 +0000</pubDate>
      <link>https://forem.com/hasnain01hub/multi-factormfa-authentication-in-react-js-using-firebase-ljo</link>
      <guid>https://forem.com/hasnain01hub/multi-factormfa-authentication-in-react-js-using-firebase-ljo</guid>
      <description>&lt;p&gt;So, in July 2022 Firebase added a new segment in authentication: MFA(Multi-Factor Authentication) which adds one more layer to authenticate users.&lt;/p&gt;

&lt;p&gt;What is MFA?&lt;br&gt;
&lt;code&gt;It is a secure Authentication method which is also known as two-step authentication, which first registers the user by taking his email id and password, and in the following step, the user will get the 6-digit OTP in his phone no. After passing this step user will be authenticated and redirected to the home page.&lt;br&gt;
&lt;/code&gt;Steps to integrate MFA in your React JS app:&lt;/p&gt;

&lt;p&gt;1) First create your react app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app mfaexample
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) Create a new firebase project and configure your firebase project with your react app.&lt;/p&gt;

&lt;p&gt;3) In order to have two-step authentication, first enable any authentication provider from authentication&amp;gt;Sign-in-method&lt;br&gt;
In this blog, I will cover sign-in with email and password option as the first authentication layer.&lt;/p&gt;

&lt;p&gt;4) Enable the MFA option under &lt;code&gt;authentication&amp;gt;Sign-in-method&lt;/code&gt; in the below Advanced section of your firebase project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdlwq31d7otakjuxgq11t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdlwq31d7otakjuxgq11t.png" alt="Firebase setup Image" width="800" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5) Create a Register page in which the first step is to create users using sign-in with email and password. The email needs to be verified for setting the 2-factor auth. After doing this a verification link will be sent to the email address of the newly created user. Then click on the share link the email will be verified the user data will be encrypted and stored in the local storage and will be redirected to the OTP page.&lt;br&gt;
Also check the spam folder of your email address to get the verification link.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Register.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Cryptr from "cryptr";
const cryptr = new Cryptr("myTotallySecretKey");
const registerWithEmailAndPassword = async (e) =&amp;gt; {
    e.preventDefault();
    try {
    //Form fields validation
      if (email !== "" &amp;amp;&amp;amp; password !== "" &amp;amp;&amp;amp; phone !== "") {
        if (phone.length &amp;lt; 10)
          return alert("Please enter a valid phone number");
         // Creating a new user with the email and password
        const res = await auth.createUserWithEmailAndPassword(email, password);
        const user = res.user;
        //encrypt the user data 
        const encryptedphone = cryptr.encrypt(`+91${phone}`);
        const encryptedpassword = cryptr.encrypt(password);

        const userdata = {
          email: email,
          password: encryptedpassword,
          phone: encryptedphone,
          user: user,
        };
        //Sending an verification link to user's email id
        await user
          .sendEmailVerification({ url: "http://localhost:3000/otp" })
          .then(async () =&amp;gt; {
         //Store the users details in localStorage
            window.localStorage.setItem("user", JSON.stringify(userdata));
            setEmail("");
            setPassword("");
            setPhone("");
            alert("Email sent");
          });
      } else {
        alert("Please fill all the fields");
      }
    } catch (err) {
      console.error(err);
   }
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6) The user data will be fetched from local storage and, 6-digit OTP will be sent to the registered phone number.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;OtpScreen.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {
  multiFactor,
  PhoneAuthProvider,
  PhoneMultiFactorGenerator,
  RecaptchaVerifier,
} from "firebase/auth";
import Cryptr from "cryptr";
React.useEffect(() =&amp;gt; {
  //get the user data from localStorage
    const getdata = JSON.parse(window.localStorage.getItem("user"));
   //if the data is null than redirect back to registerd page
    if (getdata === null) {
      history.push("/register");
    }
    sentotp(getdata);
  }, []);
const sentotp = async (getdata) =&amp;gt; {
  /* A listener that triggers whenever the authentication state changes. */
    auth.onAuthStateChanged(async (user) =&amp;gt; {
/* Decrypting the phone number that was encrypted in the previous step. */
      const decryptedphone = cryptr.decrypt(getdata.phone);
  /* Creating a new recaptcha verifier. */
      const recaptchaVerifier = new RecaptchaVerifier(
        "2fa-captcha",
        { size: "invisible" },
        auth
      );
      recaptchaVerifier.render();
      await multiFactor(user)
        .getSession()
        .then(function (multiFactorSession) {
          // Specify the phone number and pass the MFA session.
          const phoneInfoOptions = {
            phoneNumber: decryptedphone,
            session: multiFactorSession,
          };

          const phoneAuthProvider = new PhoneAuthProvider(auth);

          // Send SMS verification code.
          return phoneAuthProvider.verifyPhoneNumber(
            phoneInfoOptions,
            recaptchaVerifier
          );
        })
        .then(function (verificationId) {
          setverification(verificationId);
        });
    });
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;7) Add this function in OtpScreen.js, which will trigger after submitting the OTP. After the OTP is verified it will Enroll the user in the multi-factor authentication and remove the user data from the local storage.&lt;/p&gt;

&lt;p&gt;verifyotp function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const verifyotp = async (e) =&amp;gt; {
    e.preventDefault();
    try {
//get the OTP from user nad pass in PhoneAuthProvider
const cred = PhoneAuthProvider.credential(verification, otp);
const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(cred);

      const user = auth.currentUser;
/* Enrolling the user in the multi-factor authentication. */
      await user.multiFactor
        .enroll(multiFactorAssertion, "phone number")
        .then((enrollment) =&amp;gt; {
          history.push("/home");
        });
/* Removing the user from localStorage. */
      localStorage.removeItem("user");
    } catch (err) {
      alert("Invalid OTP");
      console.log(err);
    }
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;hurry! the signup part is completed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Login Part&lt;/p&gt;

&lt;p&gt;8) For the login part, pass the user credentials in signInWithEmailAndPassword function and store a boolean after successful login in local storage.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Login.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const handleSubmit = async (e) =&amp;gt; {
    e.preventDefault();
    try {
/* function that is provided by firebase to sign in a user with email and password. */
      await auth.signInWithEmailAndPassword(email, password);
    } catch (error) {
      if (error.code === "auth/multi-factor-auth-required") {
        // The user is enrolled in MFA, must be verified
        window.resolver = error.resolver;
      } else if (error.code === "auth/too-many-requests") {
        window.resolver = error.resolver;
      } else {
        console.log(error.code, error.message);
        alert("Invalid Credentials");
        return;
      }
    }
// store a true boolean after successfully login 
    window.localStorage.setItem("approvedsignin", JSON.stringify(true));
    history.push("/loginotp");
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;9) Fetch the data from local storage to check if the user has already completed the initial login step, 6-digit OTP will be sent to the registered phone number. Then pass the user entered OTP in PhoneAuthProvider function to verify it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;VerifyUser.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {
  PhoneAuthProvider,
  PhoneMultiFactorGenerator,
  RecaptchaVerifier,
} from "firebase/auth";
React.useEffect(() =&amp;gt; {
  //check if the user has completed the first login step 
    const verfifer = JSON.parse(window.localStorage.getItem("approvedsignin"));
    if (verfifer === true) {
      sendOtp();
    } else {
      history.push("/");
    }
  }, []);

const sendOtp = async () =&amp;gt; {
    const recaptchaVerifier = new RecaptchaVerifier(
      "2fa-captcha",
      { size: "invisible" },
      auth
    );
    recaptchaVerifier.render();
    const phoneOpts = {
      multiFactorHint: window.resolver.hints[0],
      session: window.resolver.session,
    };

    const phoneAuthProvider = new PhoneAuthProvider(auth);

    await phoneAuthProvider
      .verifyPhoneNumber(phoneOpts, recaptchaVerifier)
      .then((verificationId) =&amp;gt; {
        setverification(verificationId);
      });
  };

  //verify otp 
const verify = async (e) =&amp;gt; {
    e.preventDefault();
    try {
      //pass the user endtered otp
      const cred = PhoneAuthProvider.credential(verification, otp);

      const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(cred);

      const credential = await window.resolver
        .resolveSignIn(multiFactorAssertion)
        .then((enrollment) =&amp;gt; {
          auth.onAuthStateChanged(async (users) =&amp;gt; {
            if (users) {
              //Remove boolean from localStorage
              window.localStorage.removeItem("approvedsignin");
              history.push("/home");
            }
          });
        });
    } catch (err) {
      alert("Invalid OTP");
      console.log(err);
    }
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note: Add this code in OtpScreen.js and VerifyUser.js file in JSX part&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id="2fa-captcha" style={{ display: "flex", justifyContent: "center" }}&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations, the two-factor authentication is set up for your react js app 😎.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect Me!&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Linkedin&lt;/strong&gt;: linkedin.com/in/hasnain-sayyed-537164177/&lt;br&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/Hasnain01-hub" rel="noopener noreferrer"&gt;https://github.com/Hasnain01-hub&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Source Code:&lt;/strong&gt; &lt;a href="https://github.com/Hasnain01-hub/MultiFactorAuthentication-React" rel="noopener noreferrer"&gt;https://github.com/Hasnain01-hub/MultiFactorAuthentication-React&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Buy me a Coffee:&lt;/strong&gt; &lt;a href="https://www.buymeacoffee.com/hasnainsayyed" rel="noopener noreferrer"&gt;https://www.buymeacoffee.com/hasnainsayyed&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If this post finds you helpful, plz like and follow me for more such amazing upcoming content 😊&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Refs in React</title>
      <dc:creator>Hasnain01-hub</dc:creator>
      <pubDate>Sun, 18 Sep 2022 18:42:00 +0000</pubDate>
      <link>https://forem.com/hasnain01hub/refs-in-react-2pe3</link>
      <guid>https://forem.com/hasnain01hub/refs-in-react-2pe3</guid>
      <description>&lt;h1&gt;
  
  
  &lt;strong&gt;What are Refs?? anyone??&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe0ubxmirloetzzkn67ub.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe0ubxmirloetzzkn67ub.gif" alt="Image description" width="280" height="498"&gt;&lt;/a&gt;&lt;br&gt;
Don't know, I am here to help you. if You know how to manipulate the DOM(Document Object Model) using Vanilla Javascript. Then understanding this concept would be easier.&lt;br&gt;
So the ref's concept is same as using &lt;code&gt;document.getElementById&lt;/code&gt;, &lt;code&gt;document.getElementByClassName&lt;/code&gt; or &lt;code&gt;document.getElementByTagName&lt;/code&gt; in javascript. This method is used to get access of the current element or component in the DOM structure were we can manipulate it or change its CSS attribute, delete or add an element. Same in React.js the Refs hook is used to get the access of the current element, Where it passes the current element object. We can manipulate it by calling the current attribute of that object. It doesn't re-render while the element is manipulated.&lt;/p&gt;

&lt;p&gt;Lets understand it with an example:-&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

function CustomTextInput(props) {
  const Input = useRef();

  function handleClick() {
Input.current.focus();
  }

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;input
        type="text"
        ref={Input} /&amp;gt;
      &amp;lt;input
        type="button"
        value="Focus the input"
        onClick={handleClick}
      /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Css Web-kit property</title>
      <dc:creator>Hasnain01-hub</dc:creator>
      <pubDate>Wed, 21 Apr 2021 08:12:36 +0000</pubDate>
      <link>https://forem.com/hasnain01hub/css-web-kit-property-48mn</link>
      <guid>https://forem.com/hasnain01hub/css-web-kit-property-48mn</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmbnih1yt80ig792eotqp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmbnih1yt80ig792eotqp.png" alt="image" width="422" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is WebKit?
&lt;/h2&gt;

&lt;p&gt;The word ‘webkit’ has become more popular in recent times when talking about CSS and web design. However, there is still quite a bit of confusion relating to the term ‘webkit’ in terms of what it means and how it is used when coding CSS. Webkit refers to the browser rendering engine used for Apple’s Safari and Google’s Chrome browsers. It is also the CSS syntax used for CSS3 modules&lt;/p&gt;

&lt;h6&gt;
  
  
  For example, in the CSS3 code below the green square widens horizontally over a period of 2 seconds when the mouse hovers over it:
&lt;/h6&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nc"&gt;.div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
&lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c"&gt;/*Start transition effect*/&lt;/span&gt; 
&lt;span class="nl"&gt;transition-property&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;transition-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.div&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
&lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;300px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In order for the same transition effect to render on browsers using the WebKit engine, the CSS code will be as follows:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nt"&gt;-webkit-transition-property&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;width&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;-webkit-transition-duration&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;2&lt;/span&gt;&lt;span class="nt"&gt;s&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The –webkit- code will be ignored by other web browser rendering engines&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/WebKit_Extensions#webkit-only_properties" rel="noopener noreferrer"&gt;Explore more&lt;/a&gt; on this topic...  &lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>webpack</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
