-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: don't apply recaptcha requirements when it's not configured
Fixes #47
- Loading branch information
Showing
14 changed files
with
349 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from 'flarum/forum/ForumApplication'; | ||
|
||
declare module 'flarum/forum/ForumApplication' { | ||
export default interface ForumApplication { | ||
recaptchaLoaded: boolean; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
{ | ||
// Use Flarum's tsconfig as a starting point | ||
"extends": "flarum-tsconfig", | ||
// This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder | ||
// and also tells your Typescript server to read core's global typings for | ||
// access to `dayjs` and `$` in the global namespace. | ||
"include": ["src/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*"], | ||
"compilerOptions": { | ||
// This will output typings to `dist-typings` | ||
"declarationDir": "./dist-typings", | ||
"baseUrl": ".", | ||
"paths": { | ||
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"] | ||
} | ||
// Use Flarum's tsconfig as a starting point | ||
"extends": "flarum-tsconfig", | ||
// This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder | ||
// and also tells your Typescript server to read core's global typings for | ||
// access to `dayjs` and `$` in the global namespace. | ||
"include": ["src/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*"], | ||
"compilerOptions": { | ||
// This will output typings to `dist-typings` | ||
"declarationDir": "./dist-typings", | ||
"paths": { | ||
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of fof/recaptcha. | ||
* | ||
* Copyright (c) FriendsOfFlarum. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FoF\ReCaptcha; | ||
|
||
use Flarum\Api\Serializer\ForumSerializer; | ||
use Flarum\Settings\SettingsRepositoryInterface; | ||
|
||
class ForumAttributes | ||
{ | ||
/** | ||
* @var SettingsRepositoryInterface | ||
*/ | ||
protected $settings; | ||
|
||
function __construct(SettingsRepositoryInterface $settings) | ||
{ | ||
$this->settings = $settings; | ||
} | ||
|
||
public function __invoke(ForumSerializer $serializer, $model, array $attributes): array | ||
{ | ||
$attributes['fof-recaptcha.configured'] = Utils::isExtensionSetup($this->settings); | ||
$attributes['postWithoutCaptcha'] = $serializer->getActor()->hasPermission('fof-recaptcha.postWithoutCaptcha'); | ||
|
||
return $attributes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace FoF\ReCaptcha; | ||
|
||
use Flarum\Settings\SettingsRepositoryInterface; | ||
|
||
class Utils | ||
{ | ||
static function isExtensionSetup(SettingsRepositoryInterface $settings): bool | ||
{ | ||
return $settings->get('fof-recaptcha.credentials.site', "") !== "" && $settings->get('fof-recaptcha.credentials.secret', "") !== ""; | ||
} | ||
} |