2.2.5 • Published 7 months ago

@trxn/angular-authentication v2.2.5

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
7 months ago

angular-components

Installation

To install this librairy you have to install it first via npm, yarn or pnpm and install the required peerdependency @trxn/angular-tools

npm i --save @trxn/angular-tools`

After that you need to initialized the app.module.ts of your angular application.

import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

import { AngularAuthenticationModule } from '@trxn/angular-authentication';
import { AngularToolsModule } from '@trxn/angular-tools';

@NgModule({
  declarations: [AppComponent],
  imports: [
    AngularToolsModule.forRoot({
      environment: {
        api: {
          uri: 'http://localhost:4200/api',
        },
        appCode: 'traxion',
        appVersion: '1',
      },
    }),
    AngularAuthenticationModule.forRoot({
      environment: {
        api: {
          url: 'http://localhost:4200/api',
        },
      },
    }),
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}

Configuration

You can modify environment variables in the authentication module like in that code:

AngularAuthenticationModule.forRoot({
  environment: {
    api: {
      url: 'http://localhost:4200/api',
    },
    routing: {
      prefix: ['/'],
    },
    login: {
      url: 'login',
      routing: 'sign-in',
      redirect: ['/'],
    },
    logout: {
      url: 'logout',
      redirect: ['/'],
    },
    session: {
      url: 'me',
    },
  },
});

Here are the list of environment variables:

  • api.url(string): contain the api url
  • login:
      • url(string): contain the api path to login endpoint. Will be aggregate to the api.url
      • routing(string): contain the routing of the login component. Will be aggregate to the routing.prefix
      • redicrect(string[]): contain the path where user will be redirect after successful login
  • logout:
      • url(string): contain the api path to logout endpoint. Will be aggregate to the api.url
      • redirect(string[]): contain the path where user will be redirect after successful logout
  • session.url(string): contain the api path to session endpoint. Will be aggregate to the api.url
  • routing.prefix(string[]): contain the path where the authetification routing is inizialized (more information in routing section)

Routing

Auto routing

This package contain a routing module with to route (login and logout). To use it you just have to add this routing module in your app.module.ts

import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

import { AngularAuthenticationRoutingModule } from '@trxn/angular-authentication';

@NgModule({
  declarations: [AppComponent],
  imports: [AngularAuthenticationRoutingModule],
  bootstrap: [AppComponent],
})
export class AppModule {}

This will create two routes:

  • /login: login route
  • /logout: logout route

NB: this Module will not work without AngularToolsModule and AngularAuthenticationModule.

Custom routing

In case you want to use other routing path, you can directly access the two components of login and logout.

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import {
  LogoutComponent,
  LoginComponent,
} from '@trxn/angular-authentication';

const routes: Routes = [
  {
    path: 'login',
    component: LoginComponent,
    data: {
      title: 'Login',
    },
  },
  {
    path: 'logout',
    component: LogoutComponent,
    data: {
      title: 'Logout',
    },
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
})
export class AppRoutingModule {}

NB: If you decide to use that component has a children of a path, don't forget to change the config routing.prefix.

Backend

This package was done to work with @trxn/nestjs-authentication as backend. Check there readme for more information.

2.2.3

10 months ago

2.2.5

7 months ago

2.2.4

9 months ago

2.2.1

12 months ago

2.2.2

12 months ago

2.2.0

1 year ago

2.1.14

1 year ago

2.2.0-next.2

1 year ago

2.2.0-next.3

1 year ago

2.1.14-next.0

1 year ago

2.1.9

1 year ago

2.1.12

1 year ago

2.1.13

1 year ago

2.1.10

1 year ago

2.1.11

1 year ago

2.2.0-next.0

1 year ago

2.2.0-next.1

1 year ago

2.1.4

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.8

1 year ago

2.1.7

1 year ago

2.1.0-next.1

1 year ago

2.1.0-next.0

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.3

1 year ago

2.1.0

1 year ago

2.0.11-next.1

1 year ago

2.0.11-next.0

1 year ago

2.0.11-next.3

1 year ago

2.0.11-next.2

1 year ago

2.0.13

1 year ago

2.0.11

1 year ago

2.0.12

1 year ago

2.0.9

1 year ago

2.0.10

1 year ago

2.0.8

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.0-next.2

1 year ago

2.0.0-next.0

1 year ago

2.0.0-next.1

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.65.13-next.4

1 year ago

1.65.13-next.5

1 year ago

1.65.11-beta.3

1 year ago

1.65.3

1 year ago

1.65.13-next.2

1 year ago

1.65.4

1 year ago

1.65.5

1 year ago

1.65.13-next.8

1 year ago

1.65.6

1 year ago

1.65.11-next.0

1 year ago

1.65.7

1 year ago

1.65.13-next.6

1 year ago

1.65.8

1 year ago

1.65.13-next.7

1 year ago

1.65.9

1 year ago

1.65.10

1 year ago

1.65.12

1 year ago

1.65.11

1 year ago

1.65.13-next.0

1 year ago

1.65.11-beta.0

1 year ago

1.65.13-next.1

1 year ago

1.65.11-beta.2

1 year ago

1.65.11-beta.1

1 year ago

1.65.2

1 year ago