Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/twofactor_gateway.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--appinfo/info.xml3
-rw-r--r--js/components/GatewaySettings.vue1
-rw-r--r--js/init.js16
-rw-r--r--js/views/SMSSettings.vue13
-rw-r--r--js/views/Settings.vue31
-rw-r--r--js/views/SignalSettings.vue38
-rw-r--r--js/views/TelegramSettings.vue38
-rw-r--r--lib/Provider/AProvider.php9
-rw-r--r--lib/Provider/SignalProvider.php1
-rw-r--r--lib/Provider/SmsProvider.php1
-rw-r--r--lib/Provider/TelegramProvider.php1
-rw-r--r--lib/Settings/PersonalSettings.php53
-rw-r--r--templates/personal_settings.php2
13 files changed, 134 insertions, 73 deletions
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 75e8b2e..2de4689 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -32,7 +32,4 @@
<command>OCA\TwoFactorGateway\Command\Status</command>
<command>OCA\TwoFactorGateway\Command\Test</command>
</commands>
- <settings>
- <personal>OCA\TwoFactorGateway\Settings\PersonalSettings</personal>
- </settings>
</info>
diff --git a/js/components/GatewaySettings.vue b/js/components/GatewaySettings.vue
index bfbb518..868ee8f 100644
--- a/js/components/GatewaySettings.vue
+++ b/js/components/GatewaySettings.vue
@@ -1,6 +1,5 @@
<template>
<div>
- <h3>{{ displayName }}</h3>
<div v-if="!isAvailable">
<L10n text="The {displayName} gateway is not configured."
:options="{displayName: displayName}"/>
diff --git a/js/init.js b/js/init.js
index cc3f6ae..c9364d7 100644
--- a/js/init.js
+++ b/js/init.js
@@ -1,9 +1,19 @@
import Vue from "vue"
-import SettingsView from "views/Settings.vue"
+import SignalSettings from "views/SignalSettings.vue"
+import SMSSettings from "views/SMSSettings.vue"
+import TelegramSettings from "views/TelegramSettings.vue"
Vue.config.productionTip = false
new Vue({
- render: h => h(SettingsView)
-}).$mount('#twofactor-sms-section')
+ render: h => h(SignalSettings)
+}).$mount('#twofactor-gateway-signal')
+
+new Vue({
+ render: h => h(SMSSettings)
+}).$mount('#twofactor-gateway-sms')
+
+new Vue({
+ render: h => h(TelegramSettings)
+}).$mount('#twofactor-gateway-telegram')
diff --git a/js/views/SMSSettings.vue b/js/views/SMSSettings.vue
new file mode 100644
index 0000000..b386e35
--- /dev/null
+++ b/js/views/SMSSettings.vue
@@ -0,0 +1,13 @@
+<template>
+ <GatewaySettings gateway-name="sms" display-name="SMS" />
+</template>
+
+<script>
+ import GatewaySettings from "../components/GatewaySettings.vue";
+
+ export default {
+ components: {
+ GatewaySettings,
+ }
+ };
+</script>
diff --git a/js/views/Settings.vue b/js/views/Settings.vue
deleted file mode 100644
index f3f08a7..0000000
--- a/js/views/Settings.vue
+++ /dev/null
@@ -1,31 +0,0 @@
-<template>
- <div class="section">
- <h2 data-anchor-name="sms-second-factor-auth">
- <L10n text="Message gateway second-factor auth"/>
- </h2>
- <L10n text="Here you can configure the message gateway to receive two-factor authentication codes via Signal, SMS or Telegram." />
- <GatewaySettings gateway-name="signal" display-name="Signal">
- <SignalInstructions slot="instructions" />
- </GatewaySettings>
- <GatewaySettings gateway-name="sms" display-name="SMS" />
- <GatewaySettings gateway-name="telegram" display-name="Telegram">
- <TelegramInstructions slot="instructions" />
- </GatewaySettings>
- </div>
-</template>
-
-<script>
- import L10n from "components/L10n.vue";
- import GatewaySettings from "../components/GatewaySettings.vue";
- import SignalInstructions from "../components/SignalInstructions.vue";
- import TelegramInstructions from "../components/TelegramInstructions.vue";
-
- export default {
- components: {
- TelegramInstructions,
- SignalInstructions,
- GatewaySettings,
- L10n
- }
- };
-</script>
diff --git a/js/views/SignalSettings.vue b/js/views/SignalSettings.vue
new file mode 100644
index 0000000..9f1577e
--- /dev/null
+++ b/js/views/SignalSettings.vue
@@ -0,0 +1,38 @@
+<!--
+ - @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
+ -
+ - @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
+ -
+ - @license GNU AGPL version 3 or any later version
+ -
+ - This program is free software: you can redistribute it and/or modify
+ - it under the terms of the GNU Affero General Public License as
+ - published by the Free Software Foundation, either version 3 of the
+ - License, or (at your option) any later version.
+ -
+ - This program is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ - GNU Affero General Public License for more details.
+ -
+ - You should have received a copy of the GNU Affero General Public License
+ - along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -->
+
+<template>
+ <GatewaySettings gateway-name="signal" display-name="Signal">
+ <SignalInstructions slot="instructions"/>
+ </GatewaySettings>
+</template>
+
+<script>
+ import GatewaySettings from "../components/GatewaySettings.vue";
+ import SignalInstructions from "../components/SignalInstructions.vue";
+
+ export default {
+ components: {
+ SignalInstructions,
+ GatewaySettings,
+ }
+ };
+</script>
diff --git a/js/views/TelegramSettings.vue b/js/views/TelegramSettings.vue
new file mode 100644
index 0000000..86f572b
--- /dev/null
+++ b/js/views/TelegramSettings.vue
@@ -0,0 +1,38 @@
+<!--
+ - @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
+ -
+ - @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
+ -
+ - @license GNU AGPL version 3 or any later version
+ -
+ - This program is free software: you can redistribute it and/or modify
+ - it under the terms of the GNU Affero General Public License as
+ - published by the Free Software Foundation, either version 3 of the
+ - License, or (at your option) any later version.
+ -
+ - This program is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ - GNU Affero General Public License for more details.
+ -
+ - You should have received a copy of the GNU Affero General Public License
+ - along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -->
+
+<template>
+ <GatewaySettings gateway-name="telegram" display-name="Telegram">
+ <TelegramInstructions slot="instructions"/>
+ </GatewaySettings>
+</template>
+
+<script>
+ import GatewaySettings from "../components/GatewaySettings.vue";
+ import TelegramInstructions from "../components/TelegramInstructions.vue";
+
+ export default {
+ components: {
+ TelegramInstructions,
+ GatewaySettings,
+ }
+ };
+</script>
diff --git a/lib/Provider/AProvider.php b/lib/Provider/AProvider.php
index fe7919c..171c49e 100644
--- a/lib/Provider/AProvider.php
+++ b/lib/Provider/AProvider.php
@@ -27,14 +27,17 @@ use OCA\TwoFactorGateway\Exception\SmsTransmissionException;
use OCA\TwoFactorGateway\PhoneNumberMask;
use OCA\TwoFactorGateway\Service\Gateway\IGateway;
use OCA\TwoFactorGateway\Service\StateStorage;
+use OCA\TwoFactorGateway\Settings\PersonalSettings;
+use OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings;
use OCP\Authentication\TwoFactorAuth\IProvider;
+use OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings;
use OCP\IL10N;
use OCP\ISession;
use OCP\IUser;
use OCP\Security\ISecureRandom;
use OCP\Template;
-abstract class AProvider implements IProvider {
+abstract class AProvider implements IProvider, IProvidesPersonalSettings {
const STATE_DISABLED = 0;
const STATE_START_VERIFICATION = 1;
@@ -140,4 +143,8 @@ abstract class AProvider implements IProvider {
return $this->stateStorage->get($user, $this->gatewayName)->getState() === self::STATE_ENABLED;
}
+ public function getPersonalSettings(IUser $user): IPersonalProviderSettings {
+ return new PersonalSettings($this->gatewayName);
+ }
+
}
diff --git a/lib/Provider/SignalProvider.php b/lib/Provider/SignalProvider.php
index 0e162b4..a403213 100644
--- a/lib/Provider/SignalProvider.php
+++ b/lib/Provider/SignalProvider.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace OCA\TwoFactorGateway\Provider;
-use OCA\TwoFactorGateway\Service\Gateway\IGateway;
use OCA\TwoFactorGateway\Service\Gateway\Signal\Gateway;
use OCA\TwoFactorGateway\Service\StateStorage;
use OCP\IL10N;
diff --git a/lib/Provider/SmsProvider.php b/lib/Provider/SmsProvider.php
index 297dac5..1a4a44e 100644
--- a/lib/Provider/SmsProvider.php
+++ b/lib/Provider/SmsProvider.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace OCA\TwoFactorGateway\Provider;
-use OCA\TwoFactorGateway\Service\Gateway\IGateway;
use OCA\TwoFactorGateway\Service\Gateway\SMS\Gateway;
use OCA\TwoFactorGateway\Service\StateStorage;
use OCP\IL10N;
diff --git a/lib/Provider/TelegramProvider.php b/lib/Provider/TelegramProvider.php
index ad25f75..6eb011a 100644
--- a/lib/Provider/TelegramProvider.php
+++ b/lib/Provider/TelegramProvider.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace OCA\TwoFactorGateway\Provider;
-use OCA\TwoFactorGateway\Service\Gateway\IGateway;
use OCA\TwoFactorGateway\Service\Gateway\Telegram\Gateway;
use OCA\TwoFactorGateway\Service\StateStorage;
use OCP\IL10N;
diff --git a/lib/Settings/PersonalSettings.php b/lib/Settings/PersonalSettings.php
index 5db32e8..5cd488e 100644
--- a/lib/Settings/PersonalSettings.php
+++ b/lib/Settings/PersonalSettings.php
@@ -1,6 +1,6 @@
<?php
-declare (strict_types = 1);
+declare (strict_types=1);
/**
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
@@ -23,34 +23,27 @@ declare (strict_types = 1);
namespace OCA\TwoFactorGateway\Settings;
-use OCP\AppFramework\Http\TemplateResponse;
-use OCP\Settings\ISettings;
-
-class PersonalSettings implements ISettings
-{
-
- /**
- * @return TemplateResponse
- */
- public function getForm()
- {
- return new TemplateResponse('twofactor_gateway', 'personal_settings');
- }
-
- /**
- * @return string
- */
- public function getSection()
- {
- return 'security';
- }
-
- /**
- * @return int
- */
- public function getPriority()
- {
- return 50;
- }
+use OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings;
+use OCP\Template;
+
+class PersonalSettings implements IPersonalProviderSettings {
+
+ /** @var string */
+ private $gateway;
+
+ public function __construct(string $gateway) {
+ $this->gateway = $gateway;
+ }
+
+ /**
+ * @return Template
+ *
+ * @since 15.0.0
+ */
+ public function getBody(): Template {
+ $tmpl = new Template('twofactor_gateway', 'personal_settings');
+ $tmpl->assign('gateway', $this->gateway);
+ return $tmpl;
+ }
}
diff --git a/templates/personal_settings.php b/templates/personal_settings.php
index 38c9a73..2017286 100644
--- a/templates/personal_settings.php
+++ b/templates/personal_settings.php
@@ -2,4 +2,4 @@
script('twofactor_gateway', 'build/build');
?>
-<div class="section" id="twofactor-sms-section"></div>
+<div id="twofactor-gateway-<?php print_unescaped($_['gateway']) ?>"></div>