Add all the settings stuff

This commit is contained in:
Raoul Snyman 2022-05-11 17:26:12 -07:00
parent e63f309c89
commit 66d1df4bc5
4 changed files with 45 additions and 41 deletions

View File

@ -5,20 +5,22 @@
<name>External Password</name>
<summary>An app for Nextcloud to allow an administrator to direct a user to an external site for changing their password.</summary>
<description><![CDATA[An app for Nextcloud to allow an administrator to direct a user to an external site for changing their password. This is useful in conjunction with an app like external_users.]]></description>
<version>0.0.1</version>
<version>0.1.0</version>
<licence>agpl</licence>
<author mail="raoul@snyman.info" >Raoul Snyman</author>
<namespace>ExternalPassword</namespace>
<category>customization</category>
<category>security</category>
<website>https://git.snyman.info/raoul/externalpassword</website>
<repository>https://git.snyman.info/raoul/externalpassword</repository>
<bugs>https://git.snyman.info/raoul/externalpassword/issues</bugs>
<dependencies>
<nextcloud min-version="15" max-version="15"/>
<nextcloud min-version="22"/>
</dependencies>
<navigations>
<navigation>
<name>External Password</name>
<route>externalpassword.page.index</route>
</navigation>
</navigations>
<settings>
<admin>OCA\ExternalPassword\Settings\Admin</admin>
<admin-section>OCA\ExternalPassword\Settings\AdminSection</admin-section>
<personal>OCA\ExternalPassword\Settings\Personal</personal>
<personal-section>OCA\ExternalPassword\Settings\PersonalSection</personal-section>
</settings>
</info>

View File

@ -9,7 +9,6 @@
*/
return [
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'page#do_echo', 'url' => '/echo', 'verb' => 'POST'],
['name' => 'Settings#save', 'url' => '/settings/admin/security/externalpassword', 'verb' => 'POST'],
]
];

View File

@ -1,31 +0,0 @@
<?php
namespace OCA\ExternalPassword\Controller;
use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Controller;
class PageController extends Controller {
private $userId;
public function __construct($AppName, IRequest $request, $UserId){
parent::__construct($AppName, $request);
$this->userId = $UserId;
}
/**
* CAUTION: the @Stuff turns off security checks; for this page no admin is
* required and no CSRF check. If you don't know what CSRF is, read
* it up in the docs or you might create a security hole. This is
* basically the only required method to add this exemption, don't
* add it to any other method if you don't exactly know what it does
*
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index() {
return new TemplateResponse('externalpassword', 'index'); // templates/index.php
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace OCA\ExternalPassword\Controller;
use OCP\IRequest;
use OCP\IConfig;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Controller;
class SettingsController extends Controller {
/** @var IConfig */
private $config;
public function __construct($AppName, IRequest $request, IConfig $config) {
parent::__construct($AppName, $request);
$this->config = $config;
}
/**
* @param string
*/
public function save(string $changePasswordUrl, string $descriptionText, string $buttonText): JSONResponse {
$this->config->setAppValue('externalpassword', 'changePasswordUrl', $changePasswordUrl);
$this->config->setAppValue('externalpassword', 'descriptionText', $descriptionText);
$this->config->setAppValue('externalpassword', 'buttonText', $buttonText);
$parameters = [
'changePasswordUrl' => $changePasswordUrl,
'descriptionText' => $descriptionText,
'buttonText' => $buttonText
];
return new JSONResponse($parameters);
}
}