Added the ability to enable captcha when logging in.
This commit is contained in:
parent
e059f09e2f
commit
20ed4860da
@ -6,6 +6,12 @@ APP_URL=http://localhost
|
|||||||
|
|
||||||
APP_FORCE_HTTPS=false
|
APP_FORCE_HTTPS=false
|
||||||
|
|
||||||
|
APP_CAPTCHA=false
|
||||||
|
CAPTCHA_API_DOMAIN=http://your-domain-captcha-or-IP:8081
|
||||||
|
CAPTCHA_PRIVATE_TOKEN=
|
||||||
|
CAPTCHA_STATIC_PATH=http://your-domain-captcha-or-IP:8081/captcha
|
||||||
|
CAPTCHA_PUBLIC_TOKEN=
|
||||||
|
|
||||||
APP_DEMO_MODE=false
|
APP_DEMO_MODE=false
|
||||||
APP_DEMO_EMAIL=
|
APP_DEMO_EMAIL=
|
||||||
APP_DEMO_PASSWORD=
|
APP_DEMO_PASSWORD=
|
||||||
|
@ -19,7 +19,9 @@ public function __construct(
|
|||||||
|
|
||||||
public function login(): View
|
public function login(): View
|
||||||
{
|
{
|
||||||
return view('public/login');
|
return view('public/login', [
|
||||||
|
'captcha' => config('app.captcha', false)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function authorization(AuthorizationRequest $request): RedirectResponse
|
public function authorization(AuthorizationRequest $request): RedirectResponse
|
||||||
|
@ -13,11 +13,17 @@ final class AuthorizationRequest extends FormRequest implements FormRequestDto
|
|||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
$rules = [
|
||||||
'email' => ['required', 'email', 'max:255'],
|
'email' => ['required', 'email', 'max:255'],
|
||||||
'password' => ['required', 'min:3'],
|
'password' => ['required', 'min:3'],
|
||||||
'remember' => ['nullable', 'boolean'],
|
'remember' => ['nullable', 'boolean'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (config('app.captcha', false)) {
|
||||||
|
$rules['captcha-verified'] = ['captcha'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDto(): Authorization
|
public function getDto(): Authorization
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3",
|
"php": "^8.3",
|
||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
|
"kor-elf/captcha-rule-for-laravel": "^1.0",
|
||||||
"laravel/framework": "^11.0",
|
"laravel/framework": "^11.0",
|
||||||
"laravel/sanctum": "^4.0",
|
"laravel/sanctum": "^4.0",
|
||||||
"laravel/tinker": "^2.8"
|
"laravel/tinker": "^2.8"
|
||||||
|
52
app/application/composer.lock
generated
52
app/application/composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "680bb583053c6714b7b932ef1d099191",
|
"content-hash": "94e26ab4b33fa6f72cca1475dace5690",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
@ -1045,6 +1045,56 @@
|
|||||||
],
|
],
|
||||||
"time": "2023-12-03T19:50:20+00:00"
|
"time": "2023-12-03T19:50:20+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "kor-elf/captcha-rule-for-laravel",
|
||||||
|
"version": "1.0.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.kor-elf.net/kor-elf/captcha-rule-for-laravel",
|
||||||
|
"reference": "b2c9242d51059bcd4275da6544134d8f28f08750"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"guzzlehttp/guzzle": "^7.0.1",
|
||||||
|
"illuminate/support": "^10.0|^11.0",
|
||||||
|
"php": "^8.2"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"korElf\\CaptchaRuleForLaravel\\CaptchaProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/helpers.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"korElf\\CaptchaRuleForLaravel\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Leonid Nikitin",
|
||||||
|
"email": "i@kor-elf.net",
|
||||||
|
"homepage": "https://git.kor-elf.net/kor-elf",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Validation Rule Captcha for Laravel",
|
||||||
|
"homepage": "https://git.kor-elf.net/kor-elf/captcha-rule-for-laravel",
|
||||||
|
"keywords": [
|
||||||
|
"captcha",
|
||||||
|
"laravel",
|
||||||
|
"validation"
|
||||||
|
],
|
||||||
|
"time": "2024-04-02T17:36:12+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/framework",
|
"name": "laravel/framework",
|
||||||
"version": "v11.5.0",
|
"version": "v11.5.0",
|
||||||
|
@ -42,6 +42,15 @@
|
|||||||
'demo_email' => env('APP_DEMO_EMAIL', false),
|
'demo_email' => env('APP_DEMO_EMAIL', false),
|
||||||
'demo_password' => env('APP_DEMO_PASSWORD', false),
|
'demo_password' => env('APP_DEMO_PASSWORD', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Сaptcha
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Enables or disables captcha.
|
||||||
|
*/
|
||||||
|
'captcha' => (bool) env('APP_CAPTCHA', false),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Application Debug Mode
|
| Application Debug Mode
|
||||||
|
@ -142,6 +142,7 @@
|
|||||||
'url' => 'The :attribute format is invalid.',
|
'url' => 'The :attribute format is invalid.',
|
||||||
'uuid' => 'The :attribute must be a valid UUID.',
|
'uuid' => 'The :attribute must be a valid UUID.',
|
||||||
'no_type' => 'The :attribute can only use: :type.',
|
'no_type' => 'The :attribute can only use: :type.',
|
||||||
|
'captcha' => 'Failed to pass human verification.',
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'address' => 'address',
|
'address' => 'address',
|
||||||
'age' => 'age',
|
'age' => 'age',
|
||||||
|
@ -142,6 +142,7 @@
|
|||||||
'url' => 'Значение поля :attribute имеет ошибочный формат URL.',
|
'url' => 'Значение поля :attribute имеет ошибочный формат URL.',
|
||||||
'uuid' => 'Значение поля :attribute должно быть корректным UUID.',
|
'uuid' => 'Значение поля :attribute должно быть корректным UUID.',
|
||||||
'no_type' => 'Значение поля :attribute может использовать только: :type.',
|
'no_type' => 'Значение поля :attribute может использовать только: :type.',
|
||||||
|
'captcha' => 'Не удалось пройти проверку человеком.',
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'address' => 'адрес',
|
'address' => 'адрес',
|
||||||
'age' => 'возраст',
|
'age' => 'возраст',
|
||||||
|
@ -50,6 +50,11 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@if($captcha)
|
||||||
|
<div class="form-group mb-4">
|
||||||
|
@captcha
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="d-grid">
|
<div class="d-grid">
|
||||||
<button type="submit" class="btn btn-gray-800">{{ __('Sign in') }}</button>
|
<button type="submit" class="btn btn-gray-800">{{ __('Sign in') }}</button>
|
||||||
|
@ -48,32 +48,32 @@ RUN apk --no-cache add pcre2 libbz2 libpng libwebp libjpeg-turbo icu-libs freety
|
|||||||
&& ln -sf /dev/stdout /var/log/unit.log \
|
&& ln -sf /dev/stdout /var/log/unit.log \
|
||||||
&& addgroup -S unit && adduser -S unit -G unit
|
&& addgroup -S unit && adduser -S unit -G unit
|
||||||
|
|
||||||
#FROM BUILD as APP_BUILD_FOR_PRODUCTION
|
FROM BUILD as APP_BUILD_FOR_PRODUCTION
|
||||||
#WORKDIR /home/app
|
WORKDIR /home/app
|
||||||
#
|
|
||||||
#COPY application /home/app
|
COPY application /home/app
|
||||||
#
|
|
||||||
#RUN apk --no-cache add git nodejs npm \
|
RUN apk --no-cache add git nodejs npm \
|
||||||
# && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
||||||
# && composer install --optimize-autoloader --no-dev \
|
&& composer install --optimize-autoloader --no-dev \
|
||||||
# && npm install && npm run build \
|
&& npm install && npm run build \
|
||||||
# && rm -rf /home/app/node_modules /home/app/.env
|
&& rm -rf /home/app/node_modules /home/app/.env
|
||||||
#
|
|
||||||
#
|
|
||||||
#FROM BUILD AS PRODUCTION
|
FROM BUILD AS PRODUCTION
|
||||||
#
|
|
||||||
#COPY --from=APP_BUILD_FOR_PRODUCTION /home/app /var/www/html
|
COPY --from=APP_BUILD_FOR_PRODUCTION /home/app /var/www/html
|
||||||
#COPY docker/docker-entrypoint_prod.sh /home/unit/docker-entrypoint.sh
|
COPY docker/docker-entrypoint_prod.sh /home/unit/docker-entrypoint.sh
|
||||||
#
|
|
||||||
#WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
#
|
|
||||||
#RUN chmod 755 /home/unit/docker-entrypoint.sh
|
RUN chmod 755 /home/unit/docker-entrypoint.sh
|
||||||
#
|
|
||||||
#STOPSIGNAL SIGTERM
|
STOPSIGNAL SIGTERM
|
||||||
#
|
|
||||||
#ENTRYPOINT ["/home/unit/docker-entrypoint.sh"]
|
ENTRYPOINT ["/home/unit/docker-entrypoint.sh"]
|
||||||
#EXPOSE 9000
|
EXPOSE 9000
|
||||||
#CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock", "--user", "unit", "--group", "unit"]
|
CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock", "--user", "unit", "--group", "unit"]
|
||||||
|
|
||||||
|
|
||||||
FROM BUILD AS DEVELOP
|
FROM BUILD AS DEVELOP
|
||||||
@ -105,7 +105,8 @@ FROM BUILD AS COMPOSER
|
|||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
STOPSIGNAL SIGTERM
|
STOPSIGNAL SIGTERM
|
||||||
RUN apk --no-cache add git \
|
RUN apk --no-cache add git \
|
||||||
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
||||||
|
&& mkdir /.composer && chmod 0777 /.composer
|
||||||
ENTRYPOINT ["composer"]
|
ENTRYPOINT ["composer"]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user