# @kresnik87/angular-auth

Latest version **1.1.8** (published 2022-01-04) · 0 weekly downloads

## Install

```sh
npm install @kresnik87/angular-auth
pnpm add @kresnik87/angular-auth
yarn add @kresnik87/angular-auth
bun add @kresnik87/angular-auth
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.8 |
| Published | 2022-01-04 |
| First published | 2020-11-16 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 205.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | kresnik87 |

## Links

- npm: https://www.npmjs.com/package/@kresnik87/angular-auth
- npm.io page: https://npm.io/package/@kresnik87/angular-auth

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.0.0

## Recent versions

- 1.1.8 (latest) — 2022-01-04
- 1.1.7 — 2022-01-04
- 1.1.6 — 2021-10-26
- 1.1.5 — 2021-10-26
- 1.1.4 — 2021-10-26
- 1.1.3 — 2020-12-17
- 1.1.2 — 2020-11-18
- 1.1.1 — 2020-11-16
- 1.1.0 — 2020-11-16
- 1.0.0 — 2020-11-16

## README

# Ksk-AngularAuth


## Installation

```bash
npm i @kresnik87/angular-auth
```
###Usage
 Setup in app.module.ts
```
import {AngularAuthModule, LibConfiguration} from '@kresnik87/angular-auth';
import {NgModule, Provider, APP_INITIALIZER} from '@angular/core';

 export const config: LibConfiguration = {
    rootUrl: environment.backendUrl,
    client_secret: environment.clientSecret,
    grant_type: environment.grant_type,
    client_id: environment.clientId,
    default_routes:environment.default_routes,
    oauthMode:environment.oauthMode
};

function initLibConfiguration(lib: LibConfiguration)
{
    return () =>
    {
        lib.rootUrl = environment.backendUrl;
        lib.grant_type = environment.grant_type;
        lib.client_id = environment.clientId
        lib.client_secret = environment.clientSecret;
        lib.default_routes = environment.default_routes;
        lib.oauthMode = environment.oauthMode;
    };
}

export const INIT_ENVIRONMENT: Provider = {
    provide: APP_INITIALIZER,
    useFactory: initLibConfiguration,
    deps: [LibConfiguration],
    multi: true
};

@NgModule({
    declarations: [...],
    entryComponents: [
    ],
    imports: [
        AngularAuthModule.forRoot(config),
        ...
    ],
    providers: [
        INIT_ENVIRONMENT,
        ...
    ],
    bootstrap: [...]
})
```
### Configuration Variables

### Example
```
export class LoginComponent implements OnInit {
  public email: string;
  public password: string;

  constructor(
    private authService: AuthService
  ) {
  }

  ngOnInit(): void {
  }

  public login() {
    this.authService.login(this.email, this.password, environment.auth_endpoint).then((resp) => {
     console.log(resp);
    }, reason => {
      console.log(reason);
    })
  }
}
```

---
_Source: https://npm.io/package/@kresnik87/angular-auth · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
