|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Srmklive\Authy; |
| 4 | + |
| 5 | +use Srmklive\Authy\Contracts\Auth\TwoFactor\Authenticatable as TwoFactorAuthenticatable; |
| 6 | + |
| 7 | +class AuthyFacadeAccessor |
| 8 | +{ |
| 9 | + protected $authy; |
| 10 | + |
| 11 | + public function __construct() |
| 12 | + { |
| 13 | + $this->authy = new Authy(); |
| 14 | + } |
| 15 | + |
| 16 | + /** |
| 17 | + * Determine if the given user has two-factor authentication enabled. |
| 18 | + * |
| 19 | + * @param \Srmklive\Authy\Contracts\Auth\TwoFactor\Authenticatable $user |
| 20 | + * @return bool |
| 21 | + */ |
| 22 | + public static function isEnabled(TwoFactorAuthenticatable $user) |
| 23 | + { |
| 24 | + return isset(self::$authy->getTwoFactorAuthProviderOptions()['id']); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Register the given user with the provider. |
| 29 | + * |
| 30 | + * @param \Srmklive\Authy\Contracts\Auth\TwoFactor\Authenticatable $user |
| 31 | + * @return void |
| 32 | + */ |
| 33 | + public static function register(TwoFactorAuthenticatable $user) |
| 34 | + { |
| 35 | + return self::$authy->register($user); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Send the given user authentication token |
| 40 | + * |
| 41 | + * @param \Srmklive\Authy\Contracts\Auth\TwoFactor\Authenticatable $user |
| 42 | + * @return bool |
| 43 | + */ |
| 44 | + public function sendSms(TwoFactorAuthenticatable $user) |
| 45 | + { |
| 46 | + return self::$authy->sendSms($user); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Determine if the given token is valid for the given user. |
| 51 | + * |
| 52 | + * @param \Srmklive\Authy\Contracts\Auth\TwoFactor\Authenticatable $user |
| 53 | + * @param string $token |
| 54 | + * @return bool |
| 55 | + */ |
| 56 | + public function tokenIsValid(TwoFactorAuthenticatable $user, $token) |
| 57 | + { |
| 58 | + return self::$authy->tokenIsValid($user, $token); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Delete the given user from the provider. |
| 63 | + * |
| 64 | + * @param \Srmklive\Authy\Contracts\Auth\TwoFactor\Authenticatable $user |
| 65 | + * @return bool |
| 66 | + */ |
| 67 | + public function delete(TwoFactorAuthenticatable $user) |
| 68 | + { |
| 69 | + return self::$authy->delete($user); |
| 70 | + } |
| 71 | +} |
0 commit comments