<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Parvatichad on Medium]]></title>
        <description><![CDATA[Stories by Parvatichad on Medium]]></description>
        <link>https://medium.com/@parvatichad012?source=rss-7aabd9420afb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_2uLAELWO_fLh41c</url>
            <title>Stories by Parvatichad on Medium</title>
            <link>https://medium.com/@parvatichad012?source=rss-7aabd9420afb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 00:24:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@parvatichad012/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Navigating Authentication in Angular 17: Deconstructing the Deprecated ‘CanActivate’]]></title>
            <link>https://medium.com/@parvatichad012/navigating-authentication-in-angular-17-deconstructing-the-deprecated-canactivate-ee25dd93d690?source=rss-7aabd9420afb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee25dd93d690</guid>
            <category><![CDATA[canactivate]]></category>
            <category><![CDATA[authguard]]></category>
            <category><![CDATA[angular-authentication]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Parvatichad]]></dc:creator>
            <pubDate>Thu, 11 Jan 2024 06:18:49 GMT</pubDate>
            <atom:updated>2024-01-11T06:18:49.575Z</atom:updated>
            <content:encoded><![CDATA[<h3>What are Auth Guards and Why they are used?</h3><p>Auth Guards provided by Angular that are used to control behaviour during navigation to and from various routes in the application.</p><p>Routes are used to define public and private paths in the application that help a user to navigate from one component/ module to another.</p><p>Sometimes you might need to restrict certain pages/routes to the user, in your angular application. For instance, there might be a page that can only be supposed to accessed by logged-in users. So it would be great if we could prevent users from going to this page without login into the system. This kind of functionality can be achieved by route guards.</p><p>Auth Guards as the name sounds act as a gatekeeper, determining whether a user can access a specific route based on conditions such as authentication status or user permissions.</p><p>here are several router guards provided by angular and each one takes care of different purposes. Here we are focusing on the most common use case of router guards, preventing access of particular routes of the application to some users using <strong>canActivate</strong> route guard.</p><h3>How Auth Guard Implementation has Changed in Anguar 17?</h3><p>Angular version 17 introduced a new syntax for creating route guards that do not require the use of interfaces.</p><p>According to official Angular docs, we can create a custom functional class that will inject the and Auth Service and Router service to control the navigational behaviour behind our Guards.</p><p>Let’s jump into the practical implementation of our canActivate class in a sample Students application. In this Students app, a user can only be allowed to view Students details, if it is logged in. Else the navigation will redirect to the Login page.</p><p>Let’s begin the journey.</p><h3>Step 1: Project Setup</h3><p>Start by creating a new Angular project using the Angular CLI:</p><pre>ng new angular-auth-guards-example<br>cd angular-auth-guards-example</pre><h3>Step 2: Creating Components</h3><p>Generate the necessary components to illustrate the functionality:</p><pre>ng generate component employee<br>ng generate component employee-details<br>ng generate component login</pre><p>These components will help us visualize the different parts of our application and how route protection works.</p><h3>Step 3: Implementing Auth Guard and Service</h3><h3>AuthGuard</h3><p>Create an <strong>AuthGuard</strong> to protect routes based on authentication status:</p><pre>ng generate guard auth/auth</pre><p>Edit the generated <strong>auth.guard.ts</strong> file:</p><pre>import { inject } from &#39;@angular/core&#39;;<br>import { Router } from &#39;@angular/router&#39;;</pre><pre>import { AuthService } from &#39;./auth.service&#39;;</pre><pre>export const authGuard = () =&gt; <br>  const authService = inject(AuthService);<br>  const router = inject(Router);</pre><pre>  if (authService.isLoggedIn) {<br>    return true<br>  }</pre><pre>  // Redirect to the login page<br>  return router.parseUrl(&#39;/login&#39;);<br>};</pre><h3>AuthService</h3><p>Generate an authentication service to simulate login/logout functionality:</p><pre>ng generate service auth/auth</pre><p>Edit the generated <strong>auth.service.ts</strong> file:</p><pre>// auth.service.ts</pre><pre>import { Injectable } from &#39;@angular/core&#39;;<br>import { Observable, of } from &#39;rxjs&#39;;<br>import { tap, delay } from &#39;rxjs/operators&#39;;</pre><pre>@Injectable({<br>  providedIn: &#39;root&#39;,<br>})<br>export class AuthService {<br>  isLoggedIn = false;<br>  redirectUrl: string | null = null;</pre><pre>  login(): Observable&lt;boolean&gt; {<br>    return of(true).pipe(<br>      delay(1000),<br>      tap(() =&gt; (this.isLoggedIn = true))<br>    );<br>  }</pre><pre>  logout(): void {<br>    this.isLoggedIn = false;<br>  }<br>}</pre><h3>Step 4: Configuring Route Protection</h3><p>Utilize the <strong>canActivate</strong> guard in your routing module to secure specific routes:</p><p>Edit the <strong>app.routing.ts</strong> file:</p><pre>// app-routing.module.ts</pre><pre>import { RouterModule, Routes } from &#39;@angular/router&#39;;<br>import { EmployeeComponent } from &#39;./student-list/student-list.component&#39;;<br>import { EmployeeDetailsComponent } from &#39;./student-details/student-details.component&#39;;<br>import { LoginComponent } from &#39;./login/login.component&#39;;<br>import { AuthGuard } from &#39;./auth/auth.guard&#39;;</pre><pre>export const routes: Routes = [<br>  // ... other routes ...<br>  {<br>    path: &#39;employee/:id&#39;,<br>    component: EmployeeDetailsComponent,<br>    canActivate: [AuthGuard],<br>  },<br>  // ... other routes ...<br>];</pre><h3>Step 5: Enhancing User Experience</h3><p>Improve the user experience by implementing the login functionality:</p><p>Edit the <strong>login.component.ts</strong> file:</p><pre>typescriptCopy code<br>// login.component.ts</pre><pre>import { Component } from &#39;@angular/core&#39;;<br>import { Router } from &#39;@angular/router&#39;;<br>import { AuthService } from &#39;../auth/auth.service&#39;;</pre><pre>@Component({<br>  // ... component details ...<br>})<br>export class LoginComponent {<br>  constructor(private authService: AuthService, private router: Router) {}</pre><pre>  login(): void {<br>    this.authService.login().subscribe(() =&gt; {<br>      if (this.authService.isLoggedIn) {<br>        const redirectUrl = this.authService.redirectUrl<br>          ? this.authService.redirectUrl<br>          : &#39;/employee&#39;;<br>        this.router.navigate([redirectUrl]);<br>      }<br>    });<br>  }<br>}</pre><h3>Conclusion</h3><p>As we bid adieu to the deprecated ‘CanActivate’ interface in Angular 15, the realm of authentication remains rich with possibilities. Beyond the traditional guard approach, several alternative methods and concepts stand ready to bolster your authentication strategies:</p><h3>1. CanLoad Guard:</h3><p>The <strong>CanLoad</strong> guard allows you to prevent the loading of feature modules until certain conditions are met, making it an excellent choice for optimizing performance and reducing unnecessary network requests.</p><h3>2. CanActivateChild Guard:</h3><p>Navigating within a protected route often involves child routes. The <strong>CanActivateChild</strong> guard empowers you to secure these child routes independently, offering finer-grained control over access.</p><h3>3. Resolver:</h3><p>Resolvers enable you to fetch necessary data before activating a route, a process that can be tightly integrated with authentication. By combining a resolver with authentication checks, you can ensure that users have the required data and permissions before accessing a protected route.</p><h3>4. Role-Based Access Control (RBAC):</h3><p>RBAC introduces a hierarchical access control system based on user roles. By associating roles with routes and components, you can enforce granular access control and tailor the user experience to specific roles within your application.</p><h3>5. Third-Party Authentication Providers:</h3><p>Leveraging third-party authentication providers like OAuth 2.0 or OpenID Connect can streamline the authentication process, enhancing security and offering seamless single sign-on experiences for your users.</p><h3>6. JWT (JSON Web Tokens):</h3><p>Implementing JWT-based authentication can simplify the management of user sessions. JWTs are self-contained tokens that carry user information and can be verified to ensure authenticity, reducing the need for server-side session storage.</p><h3>7. Multi-Factor Authentication (MFA):</h3><p>Enhance security by implementing MFA, requiring users to provide multiple forms of verification before accessing protected routes. MFA adds an extra layer of protection against unauthorized access.</p><h3>8. Firebase Authentication:</h3><p>Firebase provides a robust authentication service that can seamlessly integrate with your Angular application. It supports various authentication providers and offers features like passwordless sign-in and email verification.</p><p>As Angular continues to evolve, so do the tools at your disposal for crafting secure, efficient, and user-friendly authentication systems. By exploring these alternative methods and adapting them to your application’s needs, you can navigate the ever-changing landscape of authentication with confidence and innovation.</p><h3>Conclusion: Embracing Diverse Authentication Strategies</h3><p>As we bid adieu to the deprecated ‘CanActivate’ interface in Angular 15, the realm of authentication remains rich with possibilities. Beyond the traditional guard approach, several alternative methods and concepts stand ready to bolster your authentication strategies:</p><h3>1. CanLoad Guard:</h3><p>The <strong>CanLoad</strong> guard allows you to prevent the loading of feature modules until certain conditions are met, making it an excellent choice for optimizing performance and reducing unnecessary network requests.</p><h3>2. CanActivateChild Guard:</h3><p>Navigating within a protected route often involves child routes. The <strong>CanActivateChild</strong> guard empowers you to secure these child routes independently, offering finer-grained control over access.</p><h3>3. Resolver:</h3><p>Resolvers enable you to fetch necessary data before activating a route, a process that can be tightly integrated with authentication. By combining a resolver with authentication checks, you can ensure that users have the required data and permissions before accessing a protected route.</p><h3>4. Role-Based Access Control (RBAC):</h3><p>RBAC introduces a hierarchical access control system based on user roles. By associating roles with routes and components, you can enforce granular access control and tailor the user experience to specific roles within your application.</p><h3>5. Third-Party Authentication Providers:</h3><p>Leveraging third-party authentication providers like OAuth 2.0 or OpenID Connect can streamline the authentication process, enhancing security and offering seamless single sign-on experiences for your users.</p><h3>6. JWT (JSON Web Tokens):</h3><p>Implementing JWT-based authentication can simplify the management of user sessions. JWTs are self-contained tokens that carry user information and can be verified to ensure authenticity, reducing the need for server-side session storage.</p><h3>7. Multi-Factor Authentication (MFA):</h3><p>Enhance security by implementing MFA, requiring users to provide multiple forms of verification before accessing protected routes. MFA adds an extra layer of protection against unauthorized access.</p><h3>8. Firebase Authentication:</h3><p>Firebase provides a robust authentication service that can seamlessly integrate with your Angular application. It supports various authentication providers and offers features like passwordless sign-in and email verification.</p><p>As Angular continues to evolve, so do the tools at your disposal for crafting secure, efficient, and user-friendly authentication systems. By exploring these alternative methods and adapting them to your application’s needs, you can navigate the ever-changing landscape of authentication with confidence and innovation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee25dd93d690" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Optimize Images Like a Pro with ImageKit: A Short Guide”]]></title>
            <link>https://medium.com/@parvatichad012/optimize-images-like-a-pro-with-imagekit-a-short-guide-146f4873a6a3?source=rss-7aabd9420afb------2</link>
            <guid isPermaLink="false">https://medium.com/p/146f4873a6a3</guid>
            <category><![CDATA[what-is-image-kit]]></category>
            <category><![CDATA[imagekit]]></category>
            <category><![CDATA[how-to-use-image-kit]]></category>
            <dc:creator><![CDATA[Parvatichad]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 09:18:18 GMT</pubDate>
            <atom:updated>2023-08-14T09:18:18.503Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong></p><p>Want to supercharge your website’s performance and enhance user experience? Look no further! Discover the power of ImageKit — your secret weapon for image optimization.</p><p><strong>Why ImageKit?</strong></p><p>🚀 Lightning-Fast Loading: Boost website speed with smart image delivery techniques.</p><p>📐 Resize and Crop: Effortlessly resize and crop images to fit any layout.</p><p>🌈 Quality Enhancement: Maintain image quality while reducing file sizes.</p><p>⚙️ Easy Integration: Seamlessly integrate ImageKit into your existing workflow.</p><p><strong>How to Get Started:</strong></p><ol><li>Sign Up: Create a free account on ImageKit’s platform.</li><li>API Integration: Integrate ImageKit into your website using the user-friendly API.</li><li>Image Transformation: Explore a range of transformations to optimize images.</li><li>Real-Time Editing: Make dynamic changes to images without affecting URLs.</li></ol><p><strong>Conclusion:</strong></p><p>By leveraging ImageKit’s powerful features, you’ll witness significant improvements in website speed and overall performance. Enhance your users’ experience and stay ahead in the digital race with ImageKit!</p><p>🔗 <a href="https://imagekit.io/"><strong>Get Started with ImageKit</strong></a></p><p>🌐 <a href="https://docs.imagekit.io/"><strong>ImageKit Documentation</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=146f4873a6a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>