ng-interceptor-security
TypeScript icon, indicating that this package has built-in type declarations

1.0.18 • Public • Published

Interceptor Security Angular 4

Como usar

  • Instalar
npm install --save ng-interceptor-security
  • Criar um Service
ng g s redirect-interceptor
  • Implementar
...
import { InterceptorSecurityService } from 'ng-interceptor-security';
...

export class RedirectInterceptorService extends InterceptorSecurityService  {

  private authorization = 'Basic 123456-123456';
  private urlRedirect401 = '/login';
  private headers = {
    'Authorization': this.authorization,
    'Content-Type': 'application/json'
  };

  constructor(public router: Router) {
    super(router);
  }

}
  • Adicionar a Service como provider no Module
...
import { RedirectInterceptorService } from './redirect-interceptor.service';
...

...
  providers: [
    {
      provide: HTTP_INTERCEPTORS,
      useClass: RedirectInterceptorService,
      multi: true
    }
  ],
...

Package Sidebar

Install

npm i ng-interceptor-security

Weekly Downloads

3

Version

1.0.18

License

MIT

Last publish

Collaborators

  • fabianogoes