Coder Social home page Coder Social logo

bezkoder / angular-13-login-registration-example Goto Github PK

View Code? Open in Web Editor NEW
63.0 5.0 72.0 159 KB

Angular 13 Login Page & Registration example (JWT Authentication and Authorization) with Web Api

JavaScript 4.33% TypeScript 69.00% HTML 22.56% CSS 4.11%
angular angular13 jwt jwt-authentication jwt-token jwt-auth jwt-authorization authentication authorization token-based-authentication

angular-13-login-registration-example's Introduction

Angular 13 Login and Registration with JWT and Web API example

Build Angular 13 Token based Authentication & Authorization Application with Web Api and JWT (including HttpInterceptor, Router & Form Validation).

  • JWT Authentication Flow for User Registration (Signup) & User Login
  • Project Structure with HttpInterceptor, Router
  • How to implement HttpInterceptor
  • Creating Login, Signup Components with Form Validation
  • Angular Components for accessing protected Resources
  • How to add a dynamic Navigation Bar to Angular App
  • Working with Browser Session Storage

Flow for User Registration and User Login

For JWT – Token based Authentication with Web API, we’re gonna call 2 endpoints:

  • POST api/auth/signup for User Registration
  • POST api/auth/signin for User Login

You can take a look at following flow to have an overview of Requests and Responses that Angular 13 JWT Authentication & Authorization Client will make or receive.

angular-13-login-registration-flow

Angular JWT App Diagram with Router and HttpInterceptor

angular-13-login-registration-overview

For more detail, please visit the tutorial:

Angular Login and Registration with JWT and Web API example

With Spring Boot back-end

Angular + Spring Boot: JWT Authentication and Authorization example

With Node.js Express back-end

Angular + Node.js Express: JWT Authentication and Authorization example

Depending on the backend you choose, you need to open app/_helpers/auth.interceptor.js, modify the code like this:

...

// const TOKEN_HEADER_KEY = 'Authorization'; // for Spring Boot back-end
const TOKEN_HEADER_KEY = 'x-access-token';   // for Node.js Express back-end

@Injectable()
export class AuthInterceptor implements HttpInterceptor {
  ...

  intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    ...
    if (token != null) {
      // for Spring Boot back-end
      // authReq = req.clone({ headers: req.headers.set(TOKEN_HEADER_KEY, 'Bearer ' + token) });

      // for Node.js Express back-end
      authReq = req.clone({ headers: req.headers.set(TOKEN_HEADER_KEY, token) });
    }
    return next.handle(authReq);
  }
}

...

Run ng serve --port 8081 for a dev server. Navigate to http://localhost:8081/.

More practice

Angular JWT Refresh Token example with Http Interceptor

Angular CRUD Application example with Web API

Angular Pagination example | ngx-pagination

Angular File upload example with Progress bar

Fullstack with Node:

Angular + Node Express + MySQL example

Angular + Node Express + PostgreSQL example

Angular + Node Express + MongoDB example

Angular + Node Express: File upload example

Fullstack with Spring Boot:

Angular + Spring Boot + H2 Embedded Database example

Angular + Spring Boot + MySQL example

Angular + Spring Boot + PostgreSQL example

Angular + Spring Boot + MongoDB example

Angular + Spring Boot: File upload example

Fullstack with Django:

Angular + Django example

Serverless with Firebase:

Angular Firebase CRUD with Realtime DataBase | AngularFireDatabase

Angular Firestore CRUD example with AngularFireStore

Angular Firebase Storage: File Upload/Display/Delete example

Integration (run back-end & front-end on same server/port)

How to integrate Angular with Node Restful Services

How to Integrate Angular with Spring Boot Rest API

angular-13-login-registration-example's People

Contributors

tienbku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

angular-13-login-registration-example's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.