Register "Registration" as alternative login option via the new public API
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
2d327c783c
commit
9543a3670d
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* ownCloud - registration
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later. See the COPYING file.
|
||||
*
|
||||
* @author Pellaeon Lin <pellaeon@hs.ntnu.edu.tw>
|
||||
* @copyright Pellaeon Lin 2014
|
||||
*/
|
||||
|
||||
\OCP\Util::addStyle('registration', 'register-button');
|
||||
\OC_App::registerLogIn([
|
||||
'name' => \OC::$server->getL10N('registration')->t('Register'),
|
||||
'href' => \OC::$server->getURLGenerator()->linkToRoute('registration.register.askEmail'),
|
||||
'style' => 'register-button',
|
||||
]);
|
||||
|
|
@ -37,10 +37,7 @@ Send BTC to `33pStaSaf4sDUA8XBAHTq7ZDQpCVFQArxQ`
|
|||
<repository>https://github.com/nextcloud/registration</repository>
|
||||
<screenshot>https://raw.githubusercontent.com/nextcloud/registration/master/appinfo/screenshot.png</screenshot>
|
||||
<dependencies>
|
||||
<database>sqlite</database>
|
||||
<database>pgsql</database>
|
||||
<database min-version="5.5">mysql</database>
|
||||
<nextcloud min-version="17" max-version="20" />
|
||||
<nextcloud min-version="20" max-version="20" />
|
||||
</dependencies>
|
||||
<settings>
|
||||
<admin>OCA\Registration\Settings\RegistrationSettings</admin>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
|
|
@ -24,18 +26,24 @@
|
|||
namespace OCA\Registration\AppInfo;
|
||||
|
||||
use OCA\Registration\Capabilities;
|
||||
use OCA\Registration\RegistrationLoginOption;
|
||||
use OCP\AppFramework\App;
|
||||
use OC\Authentication\Token\IProvider;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
public const APP_ID = 'registration';
|
||||
|
||||
class Application extends App {
|
||||
public function __construct() {
|
||||
parent::__construct('registration');
|
||||
parent::__construct(self::APP_ID);
|
||||
}
|
||||
|
||||
$container = $this->getContainer();
|
||||
$container->registerService(IProvider::class, function ($c) {
|
||||
return \OC::$server->query(IProvider::class); // TODO needed?
|
||||
});
|
||||
public function register(IRegistrationContext $context): void {
|
||||
$context->registerAlternativeLogin(RegistrationLoginOption::class);
|
||||
$context->registerCapability(Capabilities::class);
|
||||
}
|
||||
|
||||
$container->registerCapability(Capabilities::class);
|
||||
public function boot(IBootContext $context): void {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
* @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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Registration;
|
||||
|
||||
use OCA\Registration\AppInfo\Application;
|
||||
use OCP\Authentication\IAlternativeLogin;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\Util;
|
||||
|
||||
class RegistrationLoginOption implements IAlternativeLogin {
|
||||
|
||||
/** @var IURLGenerator */
|
||||
protected $url;
|
||||
/** @var IL10N */
|
||||
protected $l;
|
||||
|
||||
public function __construct(IURLGenerator $url,
|
||||
IL10N $l) {
|
||||
$this->url = $url;
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
public function getLabel(): string {
|
||||
return $this->l->t('Register');
|
||||
}
|
||||
|
||||
public function getLink(): string {
|
||||
return $this->url->linkToRoute('registration.register.askEmail');
|
||||
}
|
||||
|
||||
public function getClass(): string {
|
||||
return 'register-button';
|
||||
}
|
||||
|
||||
public function load(): void {
|
||||
Util::addStyle(Application::APP_ID, 'register-button');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue