| @@ 22-49 (lines=28) @@ | ||
| 19 | * |
|
| 20 | * @return bool |
|
| 21 | */ |
|
| 22 | public function canEnable() |
|
| 23 | { |
|
| 24 | if (!parent::canEnable()) { |
|
| 25 | return false; |
|
| 26 | } |
|
| 27 | ||
| 28 | // check whether it is activated in the settings |
|
| 29 | /** @var XenForo_Options $options */ |
|
| 30 | $options = XenForo_Application::getOptions(); |
|
| 31 | if (!$options->threema_gateway_tfa_fast) { |
|
| 32 | return false; |
|
| 33 | } |
|
| 34 | ||
| 35 | // this 2FA mode requires end-to-end encryption |
|
| 36 | if (!$this->gatewaySettings->isEndToEnd()) { |
|
| 37 | return false; |
|
| 38 | } |
|
| 39 | ||
| 40 | // check specific permissions |
|
| 41 | if (!$this->gatewayPermissions->hasPermission('send') || |
|
| 42 | !$this->gatewayPermissions->hasPermission('receive') || |
|
| 43 | !$this->gatewayPermissions->hasPermission('fetch') |
|
| 44 | ) { |
|
| 45 | return false; |
|
| 46 | } |
|
| 47 | ||
| 48 | return true; |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Called when trying to verify user. Creates secret and registers callback |
|
| @@ 37-63 (lines=27) @@ | ||
| 34 | * |
|
| 35 | * @return bool |
|
| 36 | */ |
|
| 37 | public function canEnable() |
|
| 38 | { |
|
| 39 | if (!parent::canEnable()) { |
|
| 40 | return false; |
|
| 41 | } |
|
| 42 | ||
| 43 | // check whether it is activated in the settings |
|
| 44 | /** @var XenForo_Options $options */ |
|
| 45 | $options = XenForo_Application::getOptions(); |
|
| 46 | if (!$options->threema_gateway_tfa_reversed) { |
|
| 47 | return false; |
|
| 48 | } |
|
| 49 | ||
| 50 | // this 2FA mode requires end-to-end encryption |
|
| 51 | if (!$this->gatewaySettings->isEndToEnd()) { |
|
| 52 | return false; |
|
| 53 | } |
|
| 54 | ||
| 55 | // check specific permissions |
|
| 56 | if (!$this->gatewayPermissions->hasPermission('receive') || |
|
| 57 | !$this->gatewayPermissions->hasPermission('fetch') |
|
| 58 | ) { |
|
| 59 | return false; |
|
| 60 | } |
|
| 61 | ||
| 62 | return true; |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Called when trying to verify user. Creates secret and registers callback |
|