Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add control for common_config('site', 'closed') with apiaccountregister API. |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
fb0ba01e88612adb4047740d177b15d8 |
| User & Date: | develop@senooken.jp 2024-01-21 07:17:33 |
Context
|
2024-03-20
| ||
| 13:14 | Add checkbox check-in: f4384752c6 user: develop@senooken.jp tags: trunk | |
|
2024-01-21
| ||
| 07:17 | Add control for common_config('site', 'closed') with apiaccountregister API. check-in: fb0ba01e88 user: develop@senooken.jp tags: trunk | |
| 06:24 | Add stderr=true for testing with header check-in: 66fbfe54bb user: develop@senooken.jp tags: trunk | |
Changes
Changes to CHANGELOG.md.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # GNU social - Log of Changes ## 2.x.x - YYYY-mm-dd ### Fixed - Duplicated post with unlike between remote GNU social server ((URL)[https://notabug.org/gnusocialjp/gnusocial/issues/10)]). ## 2.0.2 - 2023-08-21 ### Added - Docker for local development. | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# GNU social - Log of Changes
## 2.x.x - YYYY-mm-dd
### Fixed
- Duplicated post with unlike between remote GNU social server ((URL)[https://notabug.org/gnusocialjp/gnusocial/issues/10)]).
- Add control for common_config('site', 'closed') with apiaccountregister API.
## 2.0.2 - 2023-08-21
### Added
- Docker for local development.
|
| ︙ | ︙ |
Changes to actions/apiaccountregister.php.
|
| | | 1 2 3 4 5 6 7 8 | <?php declare(strict_types=1); /** * StatusNet, the distributed open-source microblogging tool * * Register account * * PHP version 5 * |
| ︙ | ︙ | |||
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
if (empty($this->code)) {
common_ensure_session();
if (array_key_exists('invitecode', $_SESSION)) {
$this->code = $_SESSION['invitecode'];
}
}
if (common_config('site', 'inviteonly') && empty($this->code)) {
// TRANS: Client error displayed when trying to register to an invite-only site without an invitation.
$this->clientError(_('Sorry, only invited people can register.'), 401);
}
if (!empty($this->code)) {
| > > > > > | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
if (empty($this->code)) {
common_ensure_session();
if (array_key_exists('invitecode', $_SESSION)) {
$this->code = $_SESSION['invitecode'];
}
}
if (common_config('site', 'closed')) {
// TRANS: Client error displayed when trying to register to a closed site.
$this->clientError(_('Registration not allowed.'));
}
if (common_config('site', 'inviteonly') && empty($this->code)) {
// TRANS: Client error displayed when trying to register to an invite-only site without an invitation.
$this->clientError(_('Sorry, only invited people can register.'), 401);
}
if (!empty($this->code)) {
|
| ︙ | ︙ |
Added tests/actions/ApiAccountRegisterActionTest.php.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
define('GNUSOCIAL', true);
define('INSTALLDIR', '.');
set_include_path('../../');
require_once(INSTALLDIR . '/lib/util/framework.php');
final class ApiAccountRegisterActionTest extends TestCase
{
private $instance;
protected function setUp(): void
{
$GLOBALS['config'] = [];
$this->instance = new ApiAccountRegisterAction;
}
public function testHandle(): void
{
$GLOBALS['config']['site'] = ['closed' => true];
$this->expectExceptionMessage('Registration not allowed.');
$mock = $this->createMock('ApiAccountRegisterAction');
$mock->expects($this->any())
->method('clientError')
->willReturnCallback(function(
string $msg, int $code = 400, ?string $format = null) {
throw new \Exception($msg, $code, $format);
});
$this->doMethod($mock, 'handle', []);
}
/**
* Run with private method.
* @param object $object target object.
* @param string $methodName private method name。
* @param array $param argument for private method。
* @return mixed result。
* @throws \ReflectionException throw when missing argument。
*/
private function doMethod(object $object, string $methodName, array $param): object
{
$controller = $object;
$reflection = new \ReflectionClass($controller);
$method = $reflection->getMethod($methodName);
$method->setAccessible(true);
return $method->invokeArgs($controller, $param);
}
}
|