Let’s revisit the sample login SPA again from auth0.
-
main.tsbootstraps the app, with the app config, including auth0 provider data that includesdomain,clientId, andredirect_uri. The app uses this along with the auth0 angular SDK to communicate with your auth0 tenant. -
You can inject
AuthServicefrom any standalone component to access the auth0 angular service. For example:- In
login-button.ts- The service is injected via
private auth = inject(AuthService); - Clicking the login button calls
this.auth.loginWithRedirect();, which redirects the user to auth0 login page
- The service is injected via
- In
logout-button.tS, this is used:this.auth.logout() - In
app.tsandprofile.ts, the same auth0 Angular service is used to check for successful and failed authentication.
- In
.
├── README.md
├── angular.json
├── package-lock.json
├── package.json
├── public
│ └── favicon.ico
├── src
│ ├── app
│ │ ├── app.config.ts
│ │ ├── app.css
│ │ ├── app.html
│ │ ├── app.routes.ts
│ │ ├── app.spec.ts
│ │ ├── app.ts
│ │ └── components
│ │ ├── login-button
│ │ │ └── login-button.ts
│ │ ├── logout-button
│ │ │ └── logout-button.ts
│ │ └── profile
│ │ └── profile.ts
│ ├── environments
│ │ └── environment.ts
│ ├── index.html
│ ├── main.ts
│ └── styles.css
├── tsconfig.app.json
├── tsconfig.json
└── tsconfig.spec.json