# AuthStack Two Factor interface

Interface for handling two factor key information. 

## Use

#### Loading security keys for user

- Find the user in `users` table and get their `id`

```php
<?php

use AuthStack\TwoFactor\Collection\KeyCollection as Collection;

$user_id = 1;

$collection = Collection::loadForUser($user_id);

```

#### Verify an OTP

- Load the collection
- invoke `verifyOTP()` method

If OTP is verified, key metadata with counters is automatically updated by the collection

```php
<?php

use AuthStack\TwoFactor\Collection\KeyCollection as Collection;

$user_id = 1;

$collection = Collection::loadForUser($user_id);

$result = $collection->verifyOTP('123456');
```


#### Retrieve a list with security keys

```php
<?php

use AuthStack\TwoFactor\Collection\KeyCollection as Collection;

$user_id = 1;

$collection = Collection::loadForUser($user_id);

$list = $collection->getKeyList(); // array
```

