diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-06-25 17:58:08 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-06-25 17:58:08 +0300 |
commit | 2bd74e9fea26731a722a594979279f0c6de799ac (patch) | |
tree | a69c55a2b0e613d6a52ec8034c9a090e92bcf0d7 | |
parent | d5dbee3e1e2d4506f4945b46865aa499adddfdf8 (diff) |
Let gateways tell their name to make it more clear how users receive codes
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r-- | js/view/settings.vue | 17 | ||||
-rw-r--r-- | lib/Provider/State.php | 7 | ||||
-rw-r--r-- | lib/Service/Gateway/PlaySMSGateway.php | 9 | ||||
-rw-r--r-- | lib/Service/Gateway/SignalGateway.php | 9 | ||||
-rw-r--r-- | lib/Service/Gateway/TelegramGateway.php | 11 | ||||
-rw-r--r-- | lib/Service/Gateway/TestGateway.php | 9 | ||||
-rw-r--r-- | lib/Service/Gateway/WebSmsGateway.php | 11 | ||||
-rw-r--r-- | lib/Service/IGateway.php | 8 | ||||
-rw-r--r-- | lib/Service/SetupService.php | 2 |
9 files changed, 74 insertions, 9 deletions
diff --git a/js/view/settings.vue b/js/view/settings.vue index adeff27..1fd899d 100644 --- a/js/view/settings.vue +++ b/js/view/settings.vue @@ -1,14 +1,18 @@ <template> <div class="section"> <h2 data-anchor-name="sms-second-factor-auth"> - <l10n text="SMS second-factor auth"></l10n> + <l10n text="Message gateway second-factor auth"></l10n> </h2> <div v-if="loading"> <span class="icon-loading-small"></span> </div> <div v-else> + <p> + <l10n text="Here you can configure the message gateway to receive two-factor authentication codes via {gateway}." + v-bind:options="{gateway: gatewayName}"></l10n> + </p> <p v-if="state === 0"> - <l10n text="You are not using SMS-based two-factor authentication at the moment"></l10n> + <l10n text="You are not using gateway for two-factor authentication at the moment."></l10n> <button @click="enable"> <l10n text="Enable"></l10n> </button> @@ -24,15 +28,16 @@ </button> </p> <p v-if="state === 2"> - <l10n text="A confirmation code has been sent to {phone}. Please check your phone and insert the code here:" - v-bind:options="{phone: phoneNumber}"></l10n> + <l10n text="A confirmation code has been sent to {phone} via {gateway}. Please insert the code here:" + v-bind:options="{gateway: gatewayName, phone: phoneNumber}"></l10n> <input v-model="confirmationCode"> <button @click="confirm"> <l10n text="Confirm"></l10n> </button> </p> <p v-if="state === 3"> - <l10n text="SMS-based two-factor authentication is enabled for your account."></l10n> + <l10n text="Your account was successfully configured to receive messages via {gateway}." + v-bind:options="{gateway: gatewayName}"></l10n> <button @click="disable"> <l10n text="Disable"></l10n> </button> @@ -58,12 +63,14 @@ phoneNumber: '', confirmationCode: '', identifier: '', + gatewayName: '', verificationError: false }; }, mounted: function () { getState() .then(res => { + this.gatewayName = res.gatewayName; this.state = res.state; this.phoneNumber = res.phoneNumber; this.loading = false; diff --git a/lib/Provider/State.php b/lib/Provider/State.php index 7690603..0cb0308 100644 --- a/lib/Provider/State.php +++ b/lib/Provider/State.php @@ -28,19 +28,24 @@ use JsonSerializable; class State implements JsonSerializable { + /** @var string */ + private $gatewayName; + /** @var int */ private $state; /** @var string */ private $phoneNumber; - public function __construct(int $state, string $phoneNumber = null) { + public function __construct(string $gatewayName, int $state, string $phoneNumber = null) { + $this->gatewayName = $gatewayName; $this->state = $state; $this->phoneNumber = $phoneNumber; } public function jsonSerialize() { return [ + 'gatewayName' => $this->gatewayName, 'state' => $this->state, 'phoneNumber' => $this->phoneNumber, ]; diff --git a/lib/Service/Gateway/PlaySMSGateway.php b/lib/Service/Gateway/PlaySMSGateway.php index 1d26cb2..6a1027a 100644 --- a/lib/Service/Gateway/PlaySMSGateway.php +++ b/lib/Service/Gateway/PlaySMSGateway.php @@ -70,4 +70,13 @@ class PlaySMSGateway implements IGateway { } } + /** + * Get a short description of this gateway's name so that users know how + * their messages are delivered, e.g. "Telegram" + * + * @return string + */ + public function getShortName(): string { + return "SMS"; + } } diff --git a/lib/Service/Gateway/SignalGateway.php b/lib/Service/Gateway/SignalGateway.php index 49d27c8..9ebdb9a 100644 --- a/lib/Service/Gateway/SignalGateway.php +++ b/lib/Service/Gateway/SignalGateway.php @@ -72,4 +72,13 @@ class SignalGateway implements IGateway { } } + /** + * Get a short description of this gateway's name so that users know how + * their messages are delivered, e.g. "Telegram" + * + * @return string + */ + public function getShortName(): string { + return "Signal"; + } } diff --git a/lib/Service/Gateway/TelegramGateway.php b/lib/Service/Gateway/TelegramGateway.php index cceda6b..5b66786 100644 --- a/lib/Service/Gateway/TelegramGateway.php +++ b/lib/Service/Gateway/TelegramGateway.php @@ -58,7 +58,7 @@ class TelegramGateway implements IGateway { // TODO: token missing handling $api = new Api($token); - $chatId = $this->getChatId($user, $api, (int) $idenfier); + $chatId = $this->getChatId($user, $api, (int)$idenfier); $api->sendMessage([ 'chat_id' => $chatId, @@ -89,4 +89,13 @@ class TelegramGateway implements IGateway { return (int)$chatId; } + /** + * Get a short description of this gateway's name so that users know how + * their messages are delivered, e.g. "Telegram" + * + * @return string + */ + public function getShortName(): string { + return "Telegram"; + } } diff --git a/lib/Service/Gateway/TestGateway.php b/lib/Service/Gateway/TestGateway.php index 1b4315f..cd0fe9d 100644 --- a/lib/Service/Gateway/TestGateway.php +++ b/lib/Service/Gateway/TestGateway.php @@ -41,4 +41,13 @@ class TestGateway implements IGateway { $this->logger->info("message to <$idenfier>: $message"); } + /** + * Get a short description of this gateway's name so that users know how + * their messages are delivered, e.g. "Telegram" + * + * @return string + */ + public function getShortName(): string { + return "Test"; + } } diff --git a/lib/Service/Gateway/WebSmsGateway.php b/lib/Service/Gateway/WebSmsGateway.php index eec4975..524d930 100644 --- a/lib/Service/Gateway/WebSmsGateway.php +++ b/lib/Service/Gateway/WebSmsGateway.php @@ -1,6 +1,6 @@ <?php -declare(strict_types = 1); +declare(strict_types=1); /** * @author Christoph Wurst <christoph@winzerhof-wurst.at> @@ -70,4 +70,13 @@ class WebSmsGateway implements IGateway { } } + /** + * Get a short description of this gateway's name so that users know how + * their messages are delivered, e.g. "Telegram" + * + * @return string + */ + public function getShortName(): string { + return "SMS"; + } } diff --git a/lib/Service/IGateway.php b/lib/Service/IGateway.php index a80c013..b102643 100644 --- a/lib/Service/IGateway.php +++ b/lib/Service/IGateway.php @@ -28,6 +28,14 @@ use OCP\IUser; interface IGateway { /** + * Get a short description of this gateway's name so that users know how + * their messages are delivered, e.g. "Telegram" + * + * @return string + */ + public function getShortName(): string; + + /** * @param IUser $user * @param string $idenfier * @param string $message diff --git a/lib/Service/SetupService.php b/lib/Service/SetupService.php index 3e7ba3e..75de9b2 100644 --- a/lib/Service/SetupService.php +++ b/lib/Service/SetupService.php @@ -61,7 +61,7 @@ class SetupService { $state = $isVerified ? SmsProvider::STATE_ENABLED : SmsProvider::STATE_DISABLED; $verifiedNumber = $this->config->getUserValue($user->getUID(), 'twofactor_gateway', 'phone', null); - return new State($state, $verifiedNumber); + return new State($this->smsService->getShortName(), $state, $verifiedNumber); } /** |