Merge pull request #230 from nextcloud/techdebt/noid/use-event-to-register-login-option

Register login option via public API
This commit is contained in:
Joas Schilling 2020-07-21 20:25:48 +02:00 committed by GitHub
commit eb41b6f000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 78 additions and 36 deletions

View File

@ -21,7 +21,7 @@ addons:
env:
global:
- CORE_BRANCH=master
- APP_NAME=notifications
- APP_NAME=registration
matrix:
- DB=sqlite
@ -36,12 +36,6 @@ matrix:
env: DB=mysql
- php: 7.3
env: DB=pgsql
- php: 7.2
env: DB=sqlite CORE_BRANCH=stable19
- php: 7.2
env: DB=sqlite CORE_BRANCH=stable18
- php: 7.2
env: DB=sqlite CORE_BRANCH=stable17
fast_finish: true
before_install:

View File

@ -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',
]);

View File

@ -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>

View File

@ -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 {
}
}

View File

@ -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');
}
}