# @federico1818/passport

> An Angular library to connect with a Laravel application with laravel/passport and laravel/ui

Latest version **0.0.10** (published 2021-01-02) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @federico1818/passport
pnpm add @federico1818/passport
yarn add @federico1818/passport
bun add @federico1818/passport
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.10 |
| Published | 2021-01-02 |
| First published | 2020-06-16 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 91.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | federico1818 |
| Keywords | angular, cookies, passport, ui, laravel/passport, laravel/ui |

## Links

- npm: https://www.npmjs.com/package/@federico1818/passport
- Repository: https://github.com/federico1818/passport
- Homepage: https://github.com/federico1818/passport#readme
- Issues: https://github.com/federico1818/passport/issues
- npm.io page: https://npm.io/package/@federico1818/passport

## Dependencies (2)

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

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.0.10 (latest) — 2021-01-02
- 0.0.9 — 2021-01-01
- 0.0.8 — 2020-12-30
- 0.0.7 — 2020-12-17
- 0.0.6 — 2020-12-16
- 0.0.5 — 2020-12-16
- 0.0.4 — 2020-11-21
- 0.0.3 — 2020-11-20
- 0.0.2 — 2020-11-20
- 0.0.1 — 2020-06-16

## README

# Passport

An Angular library to connect with a Laravel application with laravel/passport and laravel/ui.

## Prerequisites

* Angular 11.0.2
* Laravel 7

## Configuration

### Configuration in Angular

1. Add oauth config to environments variable

Open ```/src/environments/environment.ts``` and add your oauth configuration.

```ts
export const environment = {
    production: false,
    oauth: {
        /* `oauth_clients` table, column: `id` */
        client_id: 'CLIENT_ID', 
        
        /* `oauth_clients` table, column: `secret` */
        client_secret: 'CLIENT_SECRET', 

        /* Example: http://localhost:8000 */
        url: 'URL'
    }
}
```

2. Setup @NgModule for the PassportModule

Open ```/src/app/app.module.ts```, inject the PassportModule, and specify your configuration.

```ts
import { BrowserModule } from '@angular/platform-browser'
import { NgModule } from '@angular/core'
import { PassportModule } from '@federico1818/passport'
import { environment } from 'src/environments/environment'
import { AppComponent } from './app.component'

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        PassportModule.forRoot(environment.oauth)
    ],
    providers: [],
    bootstrap: [AppComponent]
})

export class AppModule { }
```

### Configuration in Laravel

1. Edit ```AuthServiceProvider```

```php
public function boot()
{
    $this->registerPolicies();

    Passport::routes();
    
    Route::post('/oauth/register', '\App\Http\Controllers\Auth\RegisterController@register');
    Route::post('/password/email', '\App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
}
```

2. Edit ```routes/api.php```

```php
Auth::routes();
```


## Example use

### Login

```ts
import { OauthService } from '@federico1818/passport'

export class LoginComponent {
    constructor(
        protected oauthService: OauthService
    ) {}

    public login(form: any): void {
        this.oauthService.login(form).subscribe()
    }
}
```

### Send reset link email

```ts
import { UiService } from '@federico1818/passport'

export class PasswordComponent {
    constructor(
        protected uiService: UiService
    ) {}

    public sendResetLinkEmail(form: any): void {
        this.uiService.sendResetLinkEmail(form, '/api/password/email').subscribe()
    }
}
```

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