first commit
This commit is contained in:
21
vendor/laravel/framework/LICENSE.md
vendored
Normal file
21
vendor/laravel/framework/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Taylor Otwell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
45
vendor/laravel/framework/README.md
vendored
Normal file
45
vendor/laravel/framework/README.md
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://laravel.com/assets/img/components/logo-laravel.svg"></a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## About Laravel
|
||||
|
||||
> **Note:** This repository contains the core code of the Laravel framework. If you want to build an application using Laravel 5, visit the main [Laravel repository](https://github.com/laravel/laravel).
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, yet powerful, providing tools needed for large, robust applications. A superb combination of simplicity, elegance, and innovation gives you a complete toolset required to build any application with which you are tasked.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
Laravel has the most extensive and thorough documentation and video tutorial library of any modern web application framework. The [Laravel documentation](https://laravel.com/docs) is in-depth and complete, making it a breeze to get started learning the framework.
|
||||
|
||||
If you're not in the mood to read, [Laracasts](https://laracasts.com) contains over 1100 video tutorials covering a range of topics including Laravel, modern PHP, unit testing, JavaScript, and more. Boost the skill level of yourself and your entire team by digging into our comprehensive video library.
|
||||
|
||||
## Contributing
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](CODE_OF_CONDUCT.md).
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
Please review [our security policy](https://github.com/laravel/framework/security/policy) on how to report security vulnerabilities.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
102
vendor/laravel/framework/SECURITY.md
vendored
Normal file
102
vendor/laravel/framework/SECURITY.md
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
# Security Policy
|
||||
|
||||
**PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY, [SEE BELOW](#reporting-a-vulnerability).**
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Version | Security Fixes Until
|
||||
--- | ---
|
||||
5.8 | February 26th, 2020
|
||||
5.7 | September 4th, 2019
|
||||
5.6 | February 7th, 2019
|
||||
5.5 (LTS) | August 30th, 2020
|
||||
5.4 | January 24th, 2018
|
||||
5.3 | August 23rd, 2017
|
||||
5.2 | December 21st, 2016
|
||||
5.1 (LTS) | June 9th, 2018
|
||||
5.0 | February 4th, 2016
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an email to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
|
||||
|
||||
### Public PGP Key
|
||||
|
||||
```
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: OpenPGP v2.0.8
|
||||
Comment: https://sela.io/pgp/
|
||||
|
||||
xsFNBFugFSQBEACxEKhIY9IoJzcouVTIYKJfWFGvwFgbRjQWBiH3QdHId5vCrbWo
|
||||
s2l+4Rv03gMG+yHLJ3rWElnNdRaNdQv59+lShrZF7Bvu7Zvc0mMNmFOM/mQ/K2Lt
|
||||
OK/8bh6iwNNbEuyOhNQlarEy/w8hF8Yf55hBeu/rajGtcyURJDloQ/vNzcx4RWGK
|
||||
G3CLr8ka7zPYIjIFUvHLt27mcYFF9F4/G7b4HKpn75ICKC4vPoQSaYNAHlHQBLFb
|
||||
Jg/WPl93SySHLugU5F58sICs+fBZadXYQG5dWmbaF5OWB1K2XgRs45BQaBzf/8oS
|
||||
qq0scN8wVhAdBeYlVFf0ImDOxGlZ2suLK1BKJboR6zCIkBAwufKss4NV1R9KSUMv
|
||||
YGn3mq13PGme0QoIkvQkua5VjTwWfQx7wFDxZ3VQSsjIlbVyRL/Ac/hq71eAmiIR
|
||||
t6ZMNMPFpuSwBfYimrXqqb4EOffrfsTzRenG1Cxm4jNZRzX/6P4an7F/euoqXeXZ
|
||||
h37TiC7df+eHKcBI4mL+qOW4ibBqg8WwWPJ+jvuhANyQpRVzf3NNEOwJYCNbQPM/
|
||||
PbqYvMruAH+gg7uyu9u0jX3o/yLSxJMV7kF4x/SCDuBKIxSSUI4cgbjIlnxWLXZC
|
||||
wl7KW4xAKkerO3wgIPnxNfxQoiYiEKA1c3PShWRA0wHIMt3rVRJxwGM4CwARAQAB
|
||||
zRJ0YXlsb3JAbGFyYXZlbC5jb23CwXAEEwEKABoFAlugFSQCGy8DCwkHAxUKCAIe
|
||||
AQIXgAIZAQAKCRDKAI7r/Ml7Zo0SD/9zwu9K87rbqXbvZ3TVu7TnN+z7mPvVBzl+
|
||||
SFEK360TYq8a4GosghZuGm4aNEyZ90CeUjPQwc5fHwa26tIwqgLRppsG21B/mZwu
|
||||
0m8c5RaBFRFX/mCTEjlpvBkOwMJZ8f05nNdaktq6W98DbMN03neUwnpWlNSLeoNI
|
||||
u4KYZmJopNFLEax5WGaaDpmqD1J+WDr/aPHx39MUAg2ZVuC3Gj/IjYZbD1nCh0xD
|
||||
a09uDODje8a9uG33cKRBcKKPRLZjWEt5SWReLx0vsTuqJSWhCybHRBl9BQTc/JJR
|
||||
gJu5V4X3f1IYMTNRm9GggxcXrlOAiDCjE2J8ZTUt0cSxedQFnNyGfKxe/l94oTFP
|
||||
wwFHbdKhsSDZ1OyxPNIY5OHlMfMvvJaNbOw0xPPAEutPwr1aqX9sbgPeeiJwAdyw
|
||||
mPw2x/wNQvKJITRv6atw56TtLxSevQIZGPHCYTSlsIoi9jqh9/6vfq2ruMDYItCq
|
||||
+8uzei6TyH6w+fUpp/uFmcwZdrDwgNVqW+Ptu+pD2WmthqESF8UEQVoOv7OPgA5E
|
||||
ofOMaeH2ND74r2UgcXjPxZuUp1RkhHE2jJeiuLtbvOgrWwv3KOaatyEbVl+zHA1e
|
||||
1RHdJRJRPK+S7YThxxduqfOBX7E03arbbhHdS1HKhPwMc2e0hNnQDoNxQcv0GQp4
|
||||
2Y6UyCRaus7ATQRboBUkAQgA0h5j3EO2HNvp8YuT1t/VF00uUwbQaz2LIoZogqgC
|
||||
14Eb77diuIPM9MnuG7bEOnNtPVMFXxI5UYBIlzhLMxf7pfbrsoR4lq7Ld+7KMzdm
|
||||
eREqJRgUNfjZhtRZ9Z+jiFPr8AGpYxwmJk4v387uQGh1GC9JCc3CCLJoI62I9t/1
|
||||
K2b25KiOzW/FVZ/vYFj1WbISRd5GqS8SEFh4ifU79LUlJ/nEsFv4JxAXN9RqjU0e
|
||||
H4S/m1Nb24UCtYAv1JKymcf5O0G7kOzvI0w06uKxk0hNwspjDcOebD8Vv9IdYtGl
|
||||
0bn7PpBlVO1Az3s8s6Xoyyw+9Us+VLNtVka3fcrdaV/n0wARAQABwsKEBBgBCgAP
|
||||
BQJboBUkBQkPCZwAAhsuASkJEMoAjuv8yXtmwF0gBBkBCgAGBQJboBUkAAoJEA1I
|
||||
8aTLtYHmjpIH/A1ZKwTGetHFokJxsd2omvbqv+VtpAjnUbvZEi5g3yZXn+dHJV+K
|
||||
UR/DNlfGxLWEcY6datJ3ziNzzD5u8zcPp2CqeTlCxOky8F74FjEL9tN/EqUbvvmR
|
||||
td2LXsSFjHnLJRK5lYfZ3rnjKA5AjqC9MttILBovY2rI7lyVt67kbS3hMHi8AZl8
|
||||
EgihnHRJxGZjEUxyTxcB13nhfjAvxQq58LOj5754Rpe9ePSKbT8DNMjHbGpLrESz
|
||||
cmyn0VzDMLfxg8AA9uQFMwdlKqve7yRZXzeqvy08AatUpJaL7DsS4LKOItwvBub6
|
||||
tHbCE3mqrUw5lSNyUahO3vOcMAHnF7fd4W++eA//WIQKnPX5t3CwCedKn8Qkb3Ow
|
||||
oj8xUNl2T6kEtQJnO85lKBFXaMOUykopu6uB9EEXEr0ShdunOKX/UdDbkv46F2AB
|
||||
7TtltDSLB6s/QeHExSb8Jo3qra86JkDUutWdJxV7DYFUttBga8I0GqdPu4yRRoc/
|
||||
0irVXsdDY9q7jz6l7fw8mSeJR96C0Puhk70t4M1Vg/tu/ONRarXQW7fJ8kl21PcD
|
||||
UKNWWa242gji/+GLRI8AIpGMsBiX7pHhqmMMth3u7+ne5BZGGJz0uX+CzWboOHyq
|
||||
kWgfY4a62t3hM0vwnUkl/D7VgSGy4LiKQrapd3LvU2uuEfFsMu3CDicZBRXPqoXj
|
||||
PBjkkPKhwUTNlwEQrGF3QsZhNe0M9ptM2fC34qtxZtMIMB2NLvE4S621rmQ05oQv
|
||||
sT0B9WgUL3GYRKdx700+ojHEuwZ79bcLgo1dezvkfPtu/++2CXtieFthDlWHy8x5
|
||||
XJJjI1pDfGO+BgX0rS3QrQEYlF/uPQynKwxe6cGI62eZ0ug0hNrPvKEcfMLVqBQv
|
||||
w4VH6iGp9yNKMUOgAECLCs4YCxK+Eka9Prq/Gh4wuqjWiX8m66z8YvKf27sFL3fR
|
||||
OwGaz3LsnRSxbk/8oSiZuOVLfn44XRcxsHebteZat23lwD93oq54rtKnlJgmZHJY
|
||||
4vMgk1jpS4laGnvhZj7OwE0EW6AVJAEIAKJSrUvXRyK3XQnLp3Kfj82uj0St8Dt2
|
||||
h8BMeVbrAbg38wCN8XQZzVR9+bRZRR+aCzpKSqwhEQVtH7gdKgfdNdGNhG2DFAVk
|
||||
SihMhQz190FKttUZgwY00enzD7uaaA5VwNAZzRIr8skwiASB7UoO+lIhrAYgcQCA
|
||||
LpwCSMrUNB3gY1IVa2xi9FljEbS2uMABfOsTfl7z4L4T4DRv/ovDf+ihyZOXsXiH
|
||||
RVoUTIpN8ZILCZiiKubE1sMj4fSQwCs06UyDy17HbOG5/dO9awR/LHW53O3nZCxE
|
||||
JbCqr5iHa2MdHMC12+luxWJKD9DbVB01LiiPZCTkuKUDswCyi7otpVEAEQEAAcLC
|
||||
hAQYAQoADwUCW6AVJAUJDwmcAAIbLgEpCRDKAI7r/Ml7ZsBdIAQZAQoABgUCW6AV
|
||||
JAAKCRDxrCjKN7eORjt2B/9EnKVJ9lwB1JwXcQp6bZgJ21r6ghyXBssv24N9UF+v
|
||||
5QDz/tuSkTsKK1UoBrBDEinF/xTP2z+xXIeyP4c3mthMHsYdMl7AaGpcCwVJiL62
|
||||
fZvd+AiYNX3C+Bepwnwoziyhx4uPaqoezSEMD8G2WQftt6Gqttmm0Di5RVysCECF
|
||||
EyhkHwvCcbpXb5Qq+4XFzCUyaIZuGpe+oeO7U8B1CzOC16hEUu0Uhbk09Xt6dSbS
|
||||
ZERoxFjrGU+6bk424MkZkKvNS8FdTN2s3kQuHoNmhbMY+fRzKX5JNrcQ4dQQufiB
|
||||
zFcc2Ba0JVU0nYAMftTeT5ALakhwSqr3AcdD2avJZp3EYfYP/3smPGTeg1cDJV3E
|
||||
WIlCtSlhbwviUjvWEWJUE+n9MjhoUNU0TJtHIliUYUajKMG/At5wJZTXJaKVUx32
|
||||
UCWr4ioKfSzlbp1ngBuFlvU7LgZRcKbBZWvKj/KRYpxpfvPyPElmegCjAk6oiZYV
|
||||
LOV+jFfnMkk9PnR91ZZfTNx/bK+BwjOnO+g7oE8V2g2bA90vHdeSUHR52SnaVN/b
|
||||
9ytt07R0f+YtyKojuPmlNsbyAaUYUtJ1o+XNCwdVxzarYEuUabhAfDiVTu9n8wTr
|
||||
YVvnriSFOjNvOY9wdLAa56n7/qM8bzuGpoBS5SilXgJvITvQfWPvg7I9C3QhwK1S
|
||||
F6B1uquQGbBSze2wlnMbKXmhyGLlv9XpOqpkkejQo3o58B+Sqj4B8DuYixSjoknr
|
||||
pRbj8gqgqBKlcpf1wD5X9qCrl9vq19asVOHaKhiFZGxZIVbBpBOdvAKaMj4p/uln
|
||||
yklN3YFIfgmGPYbL0elvXVn7XfvwSV1mCQV5LtMbLHsFf0VsA16UsG8A/tLWtwgt
|
||||
0antzftRHXb+DI4qr+qEYKFkv9F3oCOXyH4QBhPA42EzKqhMXByEkEK9bu6skioL
|
||||
mHhDQ7yHjTWcxstqQjkUQ0T/IF9ls+Sm5u7rVXEifpyI7MCb+76kSCDawesvInKt
|
||||
WBGOG/qJGDlNiqBYYt2xNqzHCJoC
|
||||
=zXOv
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
```
|
||||
144
vendor/laravel/framework/composer.json
vendored
Normal file
144
vendor/laravel/framework/composer.json
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"description": "The Laravel Framework.",
|
||||
"keywords": ["framework", "laravel"],
|
||||
"license": "MIT",
|
||||
"homepage": "https://laravel.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-openssl": "*",
|
||||
"doctrine/inflector": "^1.1",
|
||||
"dragonmantank/cron-expression": "^2.0",
|
||||
"egulias/email-validator": "^2.0",
|
||||
"erusev/parsedown": "^1.7",
|
||||
"league/flysystem": "^1.0.8",
|
||||
"monolog/monolog": "^1.12",
|
||||
"nesbot/carbon": "^1.26.3 || ^2.0",
|
||||
"opis/closure": "^3.1",
|
||||
"psr/container": "^1.0",
|
||||
"psr/simple-cache": "^1.0",
|
||||
"ramsey/uuid": "^3.7",
|
||||
"swiftmailer/swiftmailer": "^6.0",
|
||||
"symfony/console": "^4.2",
|
||||
"symfony/debug": "^4.2",
|
||||
"symfony/finder": "^4.2",
|
||||
"symfony/http-foundation": "^4.2",
|
||||
"symfony/http-kernel": "^4.2",
|
||||
"symfony/process": "^4.2",
|
||||
"symfony/routing": "^4.2",
|
||||
"symfony/var-dumper": "^4.2",
|
||||
"tijsverkoyen/css-to-inline-styles": "^2.2.1",
|
||||
"vlucas/phpdotenv": "^3.3"
|
||||
},
|
||||
"replace": {
|
||||
"illuminate/auth": "self.version",
|
||||
"illuminate/broadcasting": "self.version",
|
||||
"illuminate/bus": "self.version",
|
||||
"illuminate/cache": "self.version",
|
||||
"illuminate/config": "self.version",
|
||||
"illuminate/console": "self.version",
|
||||
"illuminate/container": "self.version",
|
||||
"illuminate/contracts": "self.version",
|
||||
"illuminate/cookie": "self.version",
|
||||
"illuminate/database": "self.version",
|
||||
"illuminate/encryption": "self.version",
|
||||
"illuminate/events": "self.version",
|
||||
"illuminate/filesystem": "self.version",
|
||||
"illuminate/hashing": "self.version",
|
||||
"illuminate/http": "self.version",
|
||||
"illuminate/log": "self.version",
|
||||
"illuminate/mail": "self.version",
|
||||
"illuminate/notifications": "self.version",
|
||||
"illuminate/pagination": "self.version",
|
||||
"illuminate/pipeline": "self.version",
|
||||
"illuminate/queue": "self.version",
|
||||
"illuminate/redis": "self.version",
|
||||
"illuminate/routing": "self.version",
|
||||
"illuminate/session": "self.version",
|
||||
"illuminate/support": "self.version",
|
||||
"illuminate/translation": "self.version",
|
||||
"illuminate/validation": "self.version",
|
||||
"illuminate/view": "self.version"
|
||||
},
|
||||
"conflict": {
|
||||
"tightenco/collect": "<5.5.33"
|
||||
},
|
||||
"require-dev": {
|
||||
"aws/aws-sdk-php": "^3.0",
|
||||
"doctrine/dbal": "^2.6",
|
||||
"filp/whoops": "^2.1.4",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"league/flysystem-cached-adapter": "^1.0",
|
||||
"mockery/mockery": "^1.0",
|
||||
"moontoast/math": "^1.1",
|
||||
"orchestra/testbench-core": "3.8.*",
|
||||
"pda/pheanstalk": "^4.0",
|
||||
"phpunit/phpunit": "^7.5|^8.0",
|
||||
"predis/predis": "^1.1.1",
|
||||
"symfony/css-selector": "^4.2",
|
||||
"symfony/dom-crawler": "^4.2",
|
||||
"true/punycode": "^2.1"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Illuminate/Foundation/helpers.php",
|
||||
"src/Illuminate/Support/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Illuminate\\": "src/Illuminate/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"files": [
|
||||
"tests/Database/stubs/MigrationCreatorFakeMigration.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Illuminate\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"ext-pcntl": "Required to use all features of the queue worker.",
|
||||
"ext-posix": "Required to use all features of the queue worker.",
|
||||
"aws/aws-sdk-php": "Required to use the SQS queue driver and SES mail driver (^3.0).",
|
||||
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6).",
|
||||
"filp/whoops": "Required for friendly error pages in development (^2.1.4).",
|
||||
"fzaninotto/faker": "Required to use the eloquent factory builder (^1.4).",
|
||||
"guzzlehttp/guzzle": "Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (^6.0).",
|
||||
"laravel/tinker": "Required to use the tinker console command (^1.0).",
|
||||
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).",
|
||||
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).",
|
||||
"league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (^1.0).",
|
||||
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).",
|
||||
"moontoast/math": "Required to use ordered UUIDs (^1.1).",
|
||||
"nexmo/client": "Required to use the Nexmo transport (^1.0).",
|
||||
"pda/pheanstalk": "Required to use the beanstalk queue driver (^4.0).",
|
||||
"predis/predis": "Required to use the redis cache and queue drivers (^1.0).",
|
||||
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^3.0).",
|
||||
"symfony/css-selector": "Required to use some of the crawler integration testing tools (^4.2).",
|
||||
"symfony/dom-crawler": "Required to use most of the crawler integration testing tools (^4.2).",
|
||||
"symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^1.1).",
|
||||
"wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
10
vendor/laravel/framework/src/Illuminate/Auth/Access/AuthorizationException.php
vendored
Normal file
10
vendor/laravel/framework/src/Illuminate/Auth/Access/AuthorizationException.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Access;
|
||||
|
||||
use Exception;
|
||||
|
||||
class AuthorizationException extends Exception
|
||||
{
|
||||
//
|
||||
}
|
||||
754
vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php
vendored
Normal file
754
vendor/laravel/framework/src/Illuminate/Auth/Access/Gate.php
vendored
Normal file
@@ -0,0 +1,754 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Access;
|
||||
|
||||
use Exception;
|
||||
use ReflectionClass;
|
||||
use ReflectionFunction;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
||||
|
||||
class Gate implements GateContract
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* The container instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Container\Container
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* The user resolver callable.
|
||||
*
|
||||
* @var callable
|
||||
*/
|
||||
protected $userResolver;
|
||||
|
||||
/**
|
||||
* All of the defined abilities.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $abilities = [];
|
||||
|
||||
/**
|
||||
* All of the defined policies.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [];
|
||||
|
||||
/**
|
||||
* All of the registered before callbacks.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $beforeCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the registered after callbacks.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $afterCallbacks = [];
|
||||
|
||||
/**
|
||||
* All of the defined abilities using class@method notation.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $stringCallbacks = [];
|
||||
|
||||
/**
|
||||
* The callback to be used to guess policy names.
|
||||
*
|
||||
* @var callable|null
|
||||
*/
|
||||
protected $guessPolicyNamesUsingCallback;
|
||||
|
||||
/**
|
||||
* Create a new gate instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Container\Container $container
|
||||
* @param callable $userResolver
|
||||
* @param array $abilities
|
||||
* @param array $policies
|
||||
* @param array $beforeCallbacks
|
||||
* @param array $afterCallbacks
|
||||
* @param callable|null $guessPolicyNamesUsingCallback
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Container $container, callable $userResolver, array $abilities = [],
|
||||
array $policies = [], array $beforeCallbacks = [], array $afterCallbacks = [],
|
||||
callable $guessPolicyNamesUsingCallback = null)
|
||||
{
|
||||
$this->policies = $policies;
|
||||
$this->container = $container;
|
||||
$this->abilities = $abilities;
|
||||
$this->userResolver = $userResolver;
|
||||
$this->afterCallbacks = $afterCallbacks;
|
||||
$this->beforeCallbacks = $beforeCallbacks;
|
||||
$this->guessPolicyNamesUsingCallback = $guessPolicyNamesUsingCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a given ability has been defined.
|
||||
*
|
||||
* @param string|array $ability
|
||||
* @return bool
|
||||
*/
|
||||
public function has($ability)
|
||||
{
|
||||
$abilities = is_array($ability) ? $ability : func_get_args();
|
||||
|
||||
foreach ($abilities as $ability) {
|
||||
if (! isset($this->abilities[$ability])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a new ability.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param callable|string $callback
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function define($ability, $callback)
|
||||
{
|
||||
if (is_callable($callback)) {
|
||||
$this->abilities[$ability] = $callback;
|
||||
} elseif (is_string($callback)) {
|
||||
$this->stringCallbacks[$ability] = $callback;
|
||||
|
||||
$this->abilities[$ability] = $this->buildAbilityCallback($ability, $callback);
|
||||
} else {
|
||||
throw new InvalidArgumentException("Callback must be a callable or a 'Class@method' string.");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define abilities for a resource.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $class
|
||||
* @param array|null $abilities
|
||||
* @return $this
|
||||
*/
|
||||
public function resource($name, $class, array $abilities = null)
|
||||
{
|
||||
$abilities = $abilities ?: [
|
||||
'viewAny' => 'viewAny',
|
||||
'view' => 'view',
|
||||
'create' => 'create',
|
||||
'update' => 'update',
|
||||
'delete' => 'delete',
|
||||
];
|
||||
|
||||
foreach ($abilities as $ability => $method) {
|
||||
$this->define($name.'.'.$ability, $class.'@'.$method);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the ability callback for a callback string.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param string $callback
|
||||
* @return \Closure
|
||||
*/
|
||||
protected function buildAbilityCallback($ability, $callback)
|
||||
{
|
||||
return function () use ($ability, $callback) {
|
||||
if (Str::contains($callback, '@')) {
|
||||
[$class, $method] = Str::parseCallback($callback);
|
||||
} else {
|
||||
$class = $callback;
|
||||
}
|
||||
|
||||
$policy = $this->resolvePolicy($class);
|
||||
|
||||
$arguments = func_get_args();
|
||||
|
||||
$user = array_shift($arguments);
|
||||
|
||||
$result = $this->callPolicyBefore(
|
||||
$policy, $user, $ability, $arguments
|
||||
);
|
||||
|
||||
if (! is_null($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return isset($method)
|
||||
? $policy->{$method}(...func_get_args())
|
||||
: $policy(...func_get_args());
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a policy class for a given class type.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $policy
|
||||
* @return $this
|
||||
*/
|
||||
public function policy($class, $policy)
|
||||
{
|
||||
$this->policies[$class] = $policy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to run before all Gate checks.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function before(callable $callback)
|
||||
{
|
||||
$this->beforeCallbacks[] = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to run after all Gate checks.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function after(callable $callback)
|
||||
{
|
||||
$this->afterCallbacks[] = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given ability should be granted for the current user.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param array|mixed $arguments
|
||||
* @return bool
|
||||
*/
|
||||
public function allows($ability, $arguments = [])
|
||||
{
|
||||
return $this->check($ability, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given ability should be denied for the current user.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param array|mixed $arguments
|
||||
* @return bool
|
||||
*/
|
||||
public function denies($ability, $arguments = [])
|
||||
{
|
||||
return ! $this->allows($ability, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if all of the given abilities should be granted for the current user.
|
||||
*
|
||||
* @param iterable|string $abilities
|
||||
* @param array|mixed $arguments
|
||||
* @return bool
|
||||
*/
|
||||
public function check($abilities, $arguments = [])
|
||||
{
|
||||
return collect($abilities)->every(function ($ability) use ($arguments) {
|
||||
try {
|
||||
return (bool) $this->raw($ability, $arguments);
|
||||
} catch (AuthorizationException $e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if any one of the given abilities should be granted for the current user.
|
||||
*
|
||||
* @param iterable|string $abilities
|
||||
* @param array|mixed $arguments
|
||||
* @return bool
|
||||
*/
|
||||
public function any($abilities, $arguments = [])
|
||||
{
|
||||
return collect($abilities)->contains(function ($ability) use ($arguments) {
|
||||
return $this->check($ability, $arguments);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if all of the given abilities should be denied for the current user.
|
||||
*
|
||||
* @param iterable|string $abilities
|
||||
* @param array|mixed $arguments
|
||||
* @return bool
|
||||
*/
|
||||
public function none($abilities, $arguments = [])
|
||||
{
|
||||
return ! $this->any($abilities, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given ability should be granted for the current user.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param array|mixed $arguments
|
||||
* @return \Illuminate\Auth\Access\Response
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function authorize($ability, $arguments = [])
|
||||
{
|
||||
$result = $this->raw($ability, $arguments);
|
||||
|
||||
if ($result instanceof Response) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $result ? $this->allow() : $this->deny();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw result from the authorization callback.
|
||||
*
|
||||
* @param string $ability
|
||||
* @param array|mixed $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
public function raw($ability, $arguments = [])
|
||||
{
|
||||
$arguments = Arr::wrap($arguments);
|
||||
|
||||
$user = $this->resolveUser();
|
||||
|
||||
// First we will call the "before" callbacks for the Gate. If any of these give
|
||||
// back a non-null response, we will immediately return that result in order
|
||||
// to let the developers override all checks for some authorization cases.
|
||||
$result = $this->callBeforeCallbacks(
|
||||
$user, $ability, $arguments
|
||||
);
|
||||
|
||||
if (is_null($result)) {
|
||||
$result = $this->callAuthCallback($user, $ability, $arguments);
|
||||
}
|
||||
|
||||
// After calling the authorization callback, we will call the "after" callbacks
|
||||
// that are registered with the Gate, which allows a developer to do logging
|
||||
// if that is required for this application. Then we'll return the result.
|
||||
return $this->callAfterCallbacks(
|
||||
$user, $ability, $arguments, $result
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the callback/method can be called with the given user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @param \Closure|string|array $class
|
||||
* @param string|null $method
|
||||
* @return bool
|
||||
*/
|
||||
protected function canBeCalledWithUser($user, $class, $method = null)
|
||||
{
|
||||
if (! is_null($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (! is_null($method)) {
|
||||
return $this->methodAllowsGuests($class, $method);
|
||||
}
|
||||
|
||||
if (is_array($class)) {
|
||||
$className = is_string($class[0]) ? $class[0] : get_class($class[0]);
|
||||
|
||||
return $this->methodAllowsGuests($className, $class[1]);
|
||||
}
|
||||
|
||||
return $this->callbackAllowsGuests($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given class method allows guests.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @return bool
|
||||
*/
|
||||
protected function methodAllowsGuests($class, $method)
|
||||
{
|
||||
try {
|
||||
$reflection = new ReflectionClass($class);
|
||||
|
||||
$method = $reflection->getMethod($method);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($method) {
|
||||
$parameters = $method->getParameters();
|
||||
|
||||
return isset($parameters[0]) && $this->parameterAllowsGuests($parameters[0]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the callback allows guests.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return bool
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
protected function callbackAllowsGuests($callback)
|
||||
{
|
||||
$parameters = (new ReflectionFunction($callback))->getParameters();
|
||||
|
||||
return isset($parameters[0]) && $this->parameterAllowsGuests($parameters[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given parameter allows guests.
|
||||
*
|
||||
* @param \ReflectionParameter $parameter
|
||||
* @return bool
|
||||
*/
|
||||
protected function parameterAllowsGuests($parameter)
|
||||
{
|
||||
return ($parameter->getClass() && $parameter->allowsNull()) ||
|
||||
($parameter->isDefaultValueAvailable() && is_null($parameter->getDefaultValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve and call the appropriate authorization callback.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @return bool
|
||||
*/
|
||||
protected function callAuthCallback($user, $ability, array $arguments)
|
||||
{
|
||||
$callback = $this->resolveAuthCallback($user, $ability, $arguments);
|
||||
|
||||
return $callback($user, ...$arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call all of the before callbacks and return if a result is given.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @return bool|null
|
||||
*/
|
||||
protected function callBeforeCallbacks($user, $ability, array $arguments)
|
||||
{
|
||||
foreach ($this->beforeCallbacks as $before) {
|
||||
if (! $this->canBeCalledWithUser($user, $before)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_null($result = $before($user, $ability, $arguments))) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call all of the after callbacks with check result.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @param bool $result
|
||||
* @return bool|null
|
||||
*/
|
||||
protected function callAfterCallbacks($user, $ability, array $arguments, $result)
|
||||
{
|
||||
foreach ($this->afterCallbacks as $after) {
|
||||
if (! $this->canBeCalledWithUser($user, $after)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$afterResult = $after($user, $ability, $result, $arguments);
|
||||
|
||||
$result = $result ?? $afterResult;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the callable for the given ability and arguments.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @return callable
|
||||
*/
|
||||
protected function resolveAuthCallback($user, $ability, array $arguments)
|
||||
{
|
||||
if (isset($arguments[0]) &&
|
||||
! is_null($policy = $this->getPolicyFor($arguments[0])) &&
|
||||
$callback = $this->resolvePolicyCallback($user, $ability, $arguments, $policy)) {
|
||||
return $callback;
|
||||
}
|
||||
|
||||
if (isset($this->stringCallbacks[$ability])) {
|
||||
[$class, $method] = Str::parseCallback($this->stringCallbacks[$ability]);
|
||||
|
||||
if ($this->canBeCalledWithUser($user, $class, $method ?: '__invoke')) {
|
||||
return $this->abilities[$ability];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->abilities[$ability]) &&
|
||||
$this->canBeCalledWithUser($user, $this->abilities[$ability])) {
|
||||
return $this->abilities[$ability];
|
||||
}
|
||||
|
||||
return function () {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a policy instance for a given class.
|
||||
*
|
||||
* @param object|string $class
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPolicyFor($class)
|
||||
{
|
||||
if (is_object($class)) {
|
||||
$class = get_class($class);
|
||||
}
|
||||
|
||||
if (! is_string($class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($this->policies[$class])) {
|
||||
return $this->resolvePolicy($this->policies[$class]);
|
||||
}
|
||||
|
||||
foreach ($this->guessPolicyName($class) as $guessedPolicy) {
|
||||
if (class_exists($guessedPolicy)) {
|
||||
return $this->resolvePolicy($guessedPolicy);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->policies as $expected => $policy) {
|
||||
if (is_subclass_of($class, $expected)) {
|
||||
return $this->resolvePolicy($policy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess the policy name for the given class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return array
|
||||
*/
|
||||
protected function guessPolicyName($class)
|
||||
{
|
||||
if ($this->guessPolicyNamesUsingCallback) {
|
||||
return Arr::wrap(call_user_func($this->guessPolicyNamesUsingCallback, $class));
|
||||
}
|
||||
|
||||
$classDirname = str_replace('/', '\\', dirname(str_replace('\\', '/', $class)));
|
||||
|
||||
return [$classDirname.'\\Policies\\'.class_basename($class).'Policy'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a callback to be used to guess policy names.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function guessPolicyNamesUsing(callable $callback)
|
||||
{
|
||||
$this->guessPolicyNamesUsingCallback = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a policy class instance of the given type.
|
||||
*
|
||||
* @param object|string $class
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||
*/
|
||||
public function resolvePolicy($class)
|
||||
{
|
||||
return $this->container->make($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the callback for a policy check.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @param mixed $policy
|
||||
* @return bool|callable
|
||||
*/
|
||||
protected function resolvePolicyCallback($user, $ability, array $arguments, $policy)
|
||||
{
|
||||
if (! is_callable([$policy, $this->formatAbilityToMethod($ability)])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return function () use ($user, $ability, $arguments, $policy) {
|
||||
// This callback will be responsible for calling the policy's before method and
|
||||
// running this policy method if necessary. This is used to when objects are
|
||||
// mapped to policy objects in the user's configurations or on this class.
|
||||
$result = $this->callPolicyBefore(
|
||||
$policy, $user, $ability, $arguments
|
||||
);
|
||||
|
||||
// When we receive a non-null result from this before method, we will return it
|
||||
// as the "final" results. This will allow developers to override the checks
|
||||
// in this policy to return the result for all rules defined in the class.
|
||||
if (! is_null($result)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$method = $this->formatAbilityToMethod($ability);
|
||||
|
||||
return $this->callPolicyMethod($policy, $method, $user, $arguments);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the "before" method on the given policy, if applicable.
|
||||
*
|
||||
* @param mixed $policy
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $ability
|
||||
* @param array $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
protected function callPolicyBefore($policy, $user, $ability, $arguments)
|
||||
{
|
||||
if (! method_exists($policy, 'before')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->canBeCalledWithUser($user, $policy, 'before')) {
|
||||
return $policy->before($user, $ability, ...$arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the appropriate method on the given policy.
|
||||
*
|
||||
* @param mixed $policy
|
||||
* @param string $method
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @param array $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
protected function callPolicyMethod($policy, $method, $user, array $arguments)
|
||||
{
|
||||
// If this first argument is a string, that means they are passing a class name
|
||||
// to the policy. We will remove the first argument from this argument array
|
||||
// because this policy already knows what type of models it can authorize.
|
||||
if (isset($arguments[0]) && is_string($arguments[0])) {
|
||||
array_shift($arguments);
|
||||
}
|
||||
|
||||
if (! is_callable([$policy, $method])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->canBeCalledWithUser($user, $policy, $method)) {
|
||||
return $policy->{$method}($user, ...$arguments);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the policy ability into a method name.
|
||||
*
|
||||
* @param string $ability
|
||||
* @return string
|
||||
*/
|
||||
protected function formatAbilityToMethod($ability)
|
||||
{
|
||||
return strpos($ability, '-') !== false ? Str::camel($ability) : $ability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a gate instance for the given user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|mixed $user
|
||||
* @return static
|
||||
*/
|
||||
public function forUser($user)
|
||||
{
|
||||
$callback = function () use ($user) {
|
||||
return $user;
|
||||
};
|
||||
|
||||
return new static(
|
||||
$this->container, $callback, $this->abilities,
|
||||
$this->policies, $this->beforeCallbacks, $this->afterCallbacks,
|
||||
$this->guessPolicyNamesUsingCallback
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the user from the user resolver.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function resolveUser()
|
||||
{
|
||||
return call_user_func($this->userResolver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the defined abilities.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function abilities()
|
||||
{
|
||||
return $this->abilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the defined policies.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function policies()
|
||||
{
|
||||
return $this->policies;
|
||||
}
|
||||
}
|
||||
30
vendor/laravel/framework/src/Illuminate/Auth/Access/HandlesAuthorization.php
vendored
Normal file
30
vendor/laravel/framework/src/Illuminate/Auth/Access/HandlesAuthorization.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Access;
|
||||
|
||||
trait HandlesAuthorization
|
||||
{
|
||||
/**
|
||||
* Create a new access response.
|
||||
*
|
||||
* @param string|null $message
|
||||
* @return \Illuminate\Auth\Access\Response
|
||||
*/
|
||||
protected function allow($message = null)
|
||||
{
|
||||
return new Response($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an unauthorized exception.
|
||||
*
|
||||
* @param string $message
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
protected function deny($message = 'This action is unauthorized.')
|
||||
{
|
||||
throw new AuthorizationException($message);
|
||||
}
|
||||
}
|
||||
44
vendor/laravel/framework/src/Illuminate/Auth/Access/Response.php
vendored
Normal file
44
vendor/laravel/framework/src/Illuminate/Auth/Access/Response.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Access;
|
||||
|
||||
class Response
|
||||
{
|
||||
/**
|
||||
* The response message.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* Create a new response.
|
||||
*
|
||||
* @param string|null $message
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($message = null)
|
||||
{
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response message.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string representation of the message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return (string) $this->message();
|
||||
}
|
||||
}
|
||||
299
vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php
vendored
Normal file
299
vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php
vendored
Normal file
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Closure;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Contracts\Auth\Factory as FactoryContract;
|
||||
|
||||
class AuthManager implements FactoryContract
|
||||
{
|
||||
use CreatesUserProviders;
|
||||
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* The registered custom driver creators.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customCreators = [];
|
||||
|
||||
/**
|
||||
* The array of created "drivers".
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guards = [];
|
||||
|
||||
/**
|
||||
* The user resolver shared by various services.
|
||||
*
|
||||
* Determines the default user for Gate, Request, and the Authenticatable contract.
|
||||
*
|
||||
* @var \Closure
|
||||
*/
|
||||
protected $userResolver;
|
||||
|
||||
/**
|
||||
* Create a new Auth manager instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
|
||||
$this->userResolver = function ($guard = null) {
|
||||
return $this->guard($guard)->user();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get the guard from the local cache.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return \Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard
|
||||
*/
|
||||
public function guard($name = null)
|
||||
{
|
||||
$name = $name ?: $this->getDefaultDriver();
|
||||
|
||||
return $this->guards[$name] ?? $this->guards[$name] = $this->resolve($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given guard.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function resolve($name)
|
||||
{
|
||||
$config = $this->getConfig($name);
|
||||
|
||||
if (is_null($config)) {
|
||||
throw new InvalidArgumentException("Auth guard [{$name}] is not defined.");
|
||||
}
|
||||
|
||||
if (isset($this->customCreators[$config['driver']])) {
|
||||
return $this->callCustomCreator($name, $config);
|
||||
}
|
||||
|
||||
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';
|
||||
|
||||
if (method_exists($this, $driverMethod)) {
|
||||
return $this->{$driverMethod}($name, $config);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(
|
||||
"Auth driver [{$config['driver']}] for guard [{$name}] is not defined."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call a custom driver creator.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $config
|
||||
* @return mixed
|
||||
*/
|
||||
protected function callCustomCreator($name, array $config)
|
||||
{
|
||||
return $this->customCreators[$config['driver']]($this->app, $name, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a session based authentication guard.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $config
|
||||
* @return \Illuminate\Auth\SessionGuard
|
||||
*/
|
||||
public function createSessionDriver($name, $config)
|
||||
{
|
||||
$provider = $this->createUserProvider($config['provider'] ?? null);
|
||||
|
||||
$guard = new SessionGuard($name, $provider, $this->app['session.store']);
|
||||
|
||||
// When using the remember me functionality of the authentication services we
|
||||
// will need to be set the encryption instance of the guard, which allows
|
||||
// secure, encrypted cookie values to get generated for those cookies.
|
||||
if (method_exists($guard, 'setCookieJar')) {
|
||||
$guard->setCookieJar($this->app['cookie']);
|
||||
}
|
||||
|
||||
if (method_exists($guard, 'setDispatcher')) {
|
||||
$guard->setDispatcher($this->app['events']);
|
||||
}
|
||||
|
||||
if (method_exists($guard, 'setRequest')) {
|
||||
$guard->setRequest($this->app->refresh('request', $guard, 'setRequest'));
|
||||
}
|
||||
|
||||
return $guard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a token based authentication guard.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $config
|
||||
* @return \Illuminate\Auth\TokenGuard
|
||||
*/
|
||||
public function createTokenDriver($name, $config)
|
||||
{
|
||||
// The token guard implements a basic API token based guard implementation
|
||||
// that takes an API token field from the request and matches it to the
|
||||
// user in the database or another persistence layer where users are.
|
||||
$guard = new TokenGuard(
|
||||
$this->createUserProvider($config['provider'] ?? null),
|
||||
$this->app['request'],
|
||||
$config['input_key'] ?? 'api_token',
|
||||
$config['storage_key'] ?? 'api_token',
|
||||
$config['hash'] ?? false
|
||||
);
|
||||
|
||||
$this->app->refresh('request', $guard, 'setRequest');
|
||||
|
||||
return $guard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the guard configuration.
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
protected function getConfig($name)
|
||||
{
|
||||
return $this->app['config']["auth.guards.{$name}"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default authentication driver name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->app['config']['auth.defaults.guard'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default guard driver the factory should serve.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function shouldUse($name)
|
||||
{
|
||||
$name = $name ?: $this->getDefaultDriver();
|
||||
|
||||
$this->setDefaultDriver($name);
|
||||
|
||||
$this->userResolver = function ($name = null) {
|
||||
return $this->guard($name)->user();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default authentication driver name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultDriver($name)
|
||||
{
|
||||
$this->app['config']['auth.defaults.guard'] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new callback based request guard.
|
||||
*
|
||||
* @param string $driver
|
||||
* @param callable $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function viaRequest($driver, callable $callback)
|
||||
{
|
||||
return $this->extend($driver, function () use ($callback) {
|
||||
$guard = new RequestGuard($callback, $this->app['request'], $this->createUserProvider());
|
||||
|
||||
$this->app->refresh('request', $guard, 'setRequest');
|
||||
|
||||
return $guard;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user resolver callback.
|
||||
*
|
||||
* @return \Closure
|
||||
*/
|
||||
public function userResolver()
|
||||
{
|
||||
return $this->userResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the callback to be used to resolve users.
|
||||
*
|
||||
* @param \Closure $userResolver
|
||||
* @return $this
|
||||
*/
|
||||
public function resolveUsersUsing(Closure $userResolver)
|
||||
{
|
||||
$this->userResolver = $userResolver;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom driver creator Closure.
|
||||
*
|
||||
* @param string $driver
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function extend($driver, Closure $callback)
|
||||
{
|
||||
$this->customCreators[$driver] = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom provider creator Closure.
|
||||
*
|
||||
* @param string $name
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function provider($name, Closure $callback)
|
||||
{
|
||||
$this->customProviderCreators[$name] = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
return $this->guard()->{$method}(...$parameters);
|
||||
}
|
||||
}
|
||||
106
vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php
vendored
Normal file
106
vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Auth\Access\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->registerAuthenticator();
|
||||
$this->registerUserResolver();
|
||||
$this->registerAccessGate();
|
||||
$this->registerRequestRebindHandler();
|
||||
$this->registerEventRebindHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the authenticator services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerAuthenticator()
|
||||
{
|
||||
$this->app->singleton('auth', function ($app) {
|
||||
// Once the authentication service has actually been requested by the developer
|
||||
// we will set a variable in the application indicating such. This helps us
|
||||
// know that we need to set any queued cookies in the after event later.
|
||||
$app['auth.loaded'] = true;
|
||||
|
||||
return new AuthManager($app);
|
||||
});
|
||||
|
||||
$this->app->singleton('auth.driver', function ($app) {
|
||||
return $app['auth']->guard();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a resolver for the authenticated user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerUserResolver()
|
||||
{
|
||||
$this->app->bind(
|
||||
AuthenticatableContract::class, function ($app) {
|
||||
return call_user_func($app['auth']->userResolver());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the access gate service.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerAccessGate()
|
||||
{
|
||||
$this->app->singleton(GateContract::class, function ($app) {
|
||||
return new Gate($app, function () use ($app) {
|
||||
return call_user_func($app['auth']->userResolver());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the re-binding of the request binding.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerRequestRebindHandler()
|
||||
{
|
||||
$this->app->rebinding('request', function ($app, $request) {
|
||||
$request->setUserResolver(function ($guard = null) use ($app) {
|
||||
return call_user_func($app['auth']->userResolver(), $guard);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the re-binding of the event dispatcher binding.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerEventRebindHandler()
|
||||
{
|
||||
$this->app->rebinding('events', function ($app, $dispatcher) {
|
||||
if (! $app->resolved('auth')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (method_exists($guard = $app['auth']->guard(), 'setDispatcher')) {
|
||||
$guard->setDispatcher($dispatcher);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
78
vendor/laravel/framework/src/Illuminate/Auth/Authenticatable.php
vendored
Normal file
78
vendor/laravel/framework/src/Illuminate/Auth/Authenticatable.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
trait Authenticatable
|
||||
{
|
||||
/**
|
||||
* The column name of the "remember me" token.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rememberTokenName = 'remember_token';
|
||||
|
||||
/**
|
||||
* Get the name of the unique identifier for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthIdentifierName()
|
||||
{
|
||||
return $this->getKeyName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unique identifier for the user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthIdentifier()
|
||||
{
|
||||
return $this->{$this->getAuthIdentifierName()};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token value for the "remember me" session.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getRememberToken()
|
||||
{
|
||||
if (! empty($this->getRememberTokenName())) {
|
||||
return (string) $this->{$this->getRememberTokenName()};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the token value for the "remember me" session.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setRememberToken($value)
|
||||
{
|
||||
if (! empty($this->getRememberTokenName())) {
|
||||
$this->{$this->getRememberTokenName()} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the column name for the "remember me" token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberTokenName()
|
||||
{
|
||||
return $this->rememberTokenName;
|
||||
}
|
||||
}
|
||||
58
vendor/laravel/framework/src/Illuminate/Auth/AuthenticationException.php
vendored
Normal file
58
vendor/laravel/framework/src/Illuminate/Auth/AuthenticationException.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Exception;
|
||||
|
||||
class AuthenticationException extends Exception
|
||||
{
|
||||
/**
|
||||
* All of the guards that were checked.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guards;
|
||||
|
||||
/**
|
||||
* The path the user should be redirected to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo;
|
||||
|
||||
/**
|
||||
* Create a new authentication exception.
|
||||
*
|
||||
* @param string $message
|
||||
* @param array $guards
|
||||
* @param string|null $redirectTo
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($message = 'Unauthenticated.', array $guards = [], $redirectTo = null)
|
||||
{
|
||||
parent::__construct($message);
|
||||
|
||||
$this->guards = $guards;
|
||||
$this->redirectTo = $redirectTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the guards that were checked.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function guards()
|
||||
{
|
||||
return $this->guards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path the user should be redirected to.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function redirectTo()
|
||||
{
|
||||
return $this->redirectTo;
|
||||
}
|
||||
}
|
||||
133
vendor/laravel/framework/src/Illuminate/Auth/Console/AuthMakeCommand.php
vendored
Normal file
133
vendor/laravel/framework/src/Illuminate/Auth/Console/AuthMakeCommand.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\DetectsApplicationNamespace;
|
||||
|
||||
class AuthMakeCommand extends Command
|
||||
{
|
||||
use DetectsApplicationNamespace;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'make:auth
|
||||
{--views : Only scaffold the authentication views}
|
||||
{--force : Overwrite existing views by default}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Scaffold basic login and registration views and routes';
|
||||
|
||||
/**
|
||||
* The views that need to be exported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $views = [
|
||||
'auth/login.stub' => 'auth/login.blade.php',
|
||||
'auth/register.stub' => 'auth/register.blade.php',
|
||||
'auth/verify.stub' => 'auth/verify.blade.php',
|
||||
'auth/passwords/email.stub' => 'auth/passwords/email.blade.php',
|
||||
'auth/passwords/reset.stub' => 'auth/passwords/reset.blade.php',
|
||||
'layouts/app.stub' => 'layouts/app.blade.php',
|
||||
'home.stub' => 'home.blade.php',
|
||||
];
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->createDirectories();
|
||||
|
||||
$this->exportViews();
|
||||
|
||||
if (! $this->option('views')) {
|
||||
file_put_contents(
|
||||
app_path('Http/Controllers/HomeController.php'),
|
||||
$this->compileControllerStub()
|
||||
);
|
||||
|
||||
file_put_contents(
|
||||
base_path('routes/web.php'),
|
||||
file_get_contents(__DIR__.'/stubs/make/routes.stub'),
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
|
||||
$this->info('Authentication scaffolding generated successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the directories for the files.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function createDirectories()
|
||||
{
|
||||
if (! is_dir($directory = $this->getViewPath('layouts'))) {
|
||||
mkdir($directory, 0755, true);
|
||||
}
|
||||
|
||||
if (! is_dir($directory = $this->getViewPath('auth/passwords'))) {
|
||||
mkdir($directory, 0755, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the authentication views.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function exportViews()
|
||||
{
|
||||
foreach ($this->views as $key => $value) {
|
||||
if (file_exists($view = $this->getViewPath($value)) && ! $this->option('force')) {
|
||||
if (! $this->confirm("The [{$value}] view already exists. Do you want to replace it?")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
copy(
|
||||
__DIR__.'/stubs/make/views/'.$key,
|
||||
$view
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles the HomeController stub.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function compileControllerStub()
|
||||
{
|
||||
return str_replace(
|
||||
'{{namespace}}',
|
||||
$this->getAppNamespace(),
|
||||
file_get_contents(__DIR__.'/stubs/make/controllers/HomeController.stub')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full view path relative to the app's configured view path.
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
protected function getViewPath($path)
|
||||
{
|
||||
return implode(DIRECTORY_SEPARATOR, [
|
||||
config('view.paths')[0] ?? resource_path('views'), $path,
|
||||
]);
|
||||
}
|
||||
}
|
||||
34
vendor/laravel/framework/src/Illuminate/Auth/Console/ClearResetsCommand.php
vendored
Normal file
34
vendor/laravel/framework/src/Illuminate/Auth/Console/ClearResetsCommand.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ClearResetsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'auth:clear-resets {name? : The name of the password broker}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Flush expired password reset tokens';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->laravel['auth.password']->broker($this->argument('name'))->getRepository()->deleteExpired();
|
||||
|
||||
$this->info('Expired reset tokens cleared!');
|
||||
}
|
||||
}
|
||||
28
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/controllers/HomeController.stub
vendored
Normal file
28
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/controllers/HomeController.stub
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace {{namespace}}Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
||||
4
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/routes.stub
vendored
Normal file
4
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/routes.stub
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
Auth::routes();
|
||||
|
||||
Route::get('/home', 'HomeController@index')->name('home');
|
||||
73
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/login.stub
vendored
Normal file
73
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/login.stub
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">{{ __('Login') }}</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ route('login') }}">
|
||||
@csrf
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
|
||||
|
||||
@error('email')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">
|
||||
|
||||
@error('password')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-6 offset-md-4">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
|
||||
|
||||
<label class="form-check-label" for="remember">
|
||||
{{ __('Remember Me') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mb-0">
|
||||
<div class="col-md-8 offset-md-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{{ __('Login') }}
|
||||
</button>
|
||||
|
||||
@if (Route::has('password.request'))
|
||||
<a class="btn btn-link" href="{{ route('password.request') }}">
|
||||
{{ __('Forgot Your Password?') }}
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
47
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/email.stub
vendored
Normal file
47
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/email.stub
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">{{ __('Reset Password') }}</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success" role="alert">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('password.email') }}">
|
||||
@csrf
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
|
||||
|
||||
@error('email')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mb-0">
|
||||
<div class="col-md-6 offset-md-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{{ __('Send Password Reset Link') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
65
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/reset.stub
vendored
Normal file
65
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/passwords/reset.stub
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">{{ __('Reset Password') }}</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ route('password.update') }}">
|
||||
@csrf
|
||||
|
||||
<input type="hidden" name="token" value="{{ $token }}">
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ $email ?? old('email') }}" required autocomplete="email" autofocus>
|
||||
|
||||
@error('email')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
|
||||
|
||||
@error('password')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mb-0">
|
||||
<div class="col-md-6 offset-md-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{{ __('Reset Password') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
77
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/register.stub
vendored
Normal file
77
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/register.stub
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">{{ __('Register') }}</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ route('register') }}">
|
||||
@csrf
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
|
||||
|
||||
@error('name')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email">
|
||||
|
||||
@error('email')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
|
||||
|
||||
@error('password')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
|
||||
|
||||
<div class="col-md-6">
|
||||
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mb-0">
|
||||
<div class="col-md-6 offset-md-4">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{{ __('Register') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
24
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/verify.stub
vendored
Normal file
24
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/auth/verify.stub
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">{{ __('Verify Your Email Address') }}</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if (session('resent'))
|
||||
<div class="alert alert-success" role="alert">
|
||||
{{ __('A fresh verification link has been sent to your email address.') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{ __('Before proceeding, please check your email for a verification link.') }}
|
||||
{{ __('If you did not receive the email') }}, <a href="{{ route('verification.resend') }}">{{ __('click here to request another') }}</a>.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
23
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/home.stub
vendored
Normal file
23
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/home.stub
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-header">Dashboard</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success" role="alert">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
You are logged in!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
80
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub
vendored
Normal file
80
vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<!-- CSRF Token -->
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<title>{{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="{{ asset('js/app.js') }}" defer></script>
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="dns-prefetch" href="//fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
|
||||
|
||||
<!-- Styles -->
|
||||
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="{{ url('/') }}">
|
||||
{{ config('app.name', 'Laravel') }}
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<!-- Left Side Of Navbar -->
|
||||
<ul class="navbar-nav mr-auto">
|
||||
|
||||
</ul>
|
||||
|
||||
<!-- Right Side Of Navbar -->
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<!-- Authentication Links -->
|
||||
@guest
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
|
||||
</li>
|
||||
@if (Route::has('register'))
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
|
||||
</li>
|
||||
@endif
|
||||
@else
|
||||
<li class="nav-item dropdown">
|
||||
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
|
||||
{{ Auth::user()->name }} <span class="caret"></span>
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
|
||||
<a class="dropdown-item" href="{{ route('logout') }}"
|
||||
onclick="event.preventDefault();
|
||||
document.getElementById('logout-form').submit();">
|
||||
{{ __('Logout') }}
|
||||
</a>
|
||||
|
||||
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
|
||||
@csrf
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
@endguest
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="py-4">
|
||||
@yield('content')
|
||||
</main>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
94
vendor/laravel/framework/src/Illuminate/Auth/CreatesUserProviders.php
vendored
Normal file
94
vendor/laravel/framework/src/Illuminate/Auth/CreatesUserProviders.php
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
trait CreatesUserProviders
|
||||
{
|
||||
/**
|
||||
* The registered custom provider creators.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customProviderCreators = [];
|
||||
|
||||
/**
|
||||
* Create the user provider implementation for the driver.
|
||||
*
|
||||
* @param string|null $provider
|
||||
* @return \Illuminate\Contracts\Auth\UserProvider|null
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function createUserProvider($provider = null)
|
||||
{
|
||||
if (is_null($config = $this->getProviderConfiguration($provider))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($this->customProviderCreators[$driver = ($config['driver'] ?? null)])) {
|
||||
return call_user_func(
|
||||
$this->customProviderCreators[$driver], $this->app, $config
|
||||
);
|
||||
}
|
||||
|
||||
switch ($driver) {
|
||||
case 'database':
|
||||
return $this->createDatabaseProvider($config);
|
||||
case 'eloquent':
|
||||
return $this->createEloquentProvider($config);
|
||||
default:
|
||||
throw new InvalidArgumentException(
|
||||
"Authentication user provider [{$driver}] is not defined."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user provider configuration.
|
||||
*
|
||||
* @param string|null $provider
|
||||
* @return array|null
|
||||
*/
|
||||
protected function getProviderConfiguration($provider)
|
||||
{
|
||||
if ($provider = $provider ?: $this->getDefaultUserProvider()) {
|
||||
return $this->app['config']['auth.providers.'.$provider];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the database user provider.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Auth\DatabaseUserProvider
|
||||
*/
|
||||
protected function createDatabaseProvider($config)
|
||||
{
|
||||
$connection = $this->app['db']->connection();
|
||||
|
||||
return new DatabaseUserProvider($connection, $this->app['hash'], $config['table']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the Eloquent user provider.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Auth\EloquentUserProvider
|
||||
*/
|
||||
protected function createEloquentProvider($config)
|
||||
{
|
||||
return new EloquentUserProvider($this->app['hash'], $config['model']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default user provider name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultUserProvider()
|
||||
{
|
||||
return $this->app['config']['auth.defaults.provider'];
|
||||
}
|
||||
}
|
||||
159
vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
vendored
Normal file
159
vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
||||
|
||||
class DatabaseUserProvider implements UserProvider
|
||||
{
|
||||
/**
|
||||
* The active database connection.
|
||||
*
|
||||
* @var \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
protected $conn;
|
||||
|
||||
/**
|
||||
* The hasher implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
protected $hasher;
|
||||
|
||||
/**
|
||||
* The table containing the users.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table;
|
||||
|
||||
/**
|
||||
* Create a new database user provider.
|
||||
*
|
||||
* @param \Illuminate\Database\ConnectionInterface $conn
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
* @param string $table
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ConnectionInterface $conn, HasherContract $hasher, $table)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
$this->table = $table;
|
||||
$this->hasher = $hasher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by their unique identifier.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveById($identifier)
|
||||
{
|
||||
$user = $this->conn->table($this->table)->find($identifier);
|
||||
|
||||
return $this->getGenericUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by their unique identifier and "remember me" token.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @param string $token
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveByToken($identifier, $token)
|
||||
{
|
||||
$user = $this->getGenericUser(
|
||||
$this->conn->table($this->table)->find($identifier)
|
||||
);
|
||||
|
||||
return $user && $user->getRememberToken() && hash_equals($user->getRememberToken(), $token)
|
||||
? $user : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the "remember me" token for the given user in storage.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function updateRememberToken(UserContract $user, $token)
|
||||
{
|
||||
$this->conn->table($this->table)
|
||||
->where($user->getAuthIdentifierName(), $user->getAuthIdentifier())
|
||||
->update([$user->getRememberTokenName() => $token]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveByCredentials(array $credentials)
|
||||
{
|
||||
if (empty($credentials) ||
|
||||
(count($credentials) === 1 &&
|
||||
array_key_exists('password', $credentials))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// First we will add each credential element to the query as a where clause.
|
||||
// Then we can execute the query and, if we found a user, return it in a
|
||||
// generic "user" object that will be utilized by the Guard instances.
|
||||
$query = $this->conn->table($this->table);
|
||||
|
||||
foreach ($credentials as $key => $value) {
|
||||
if (Str::contains($key, 'password')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($value) || $value instanceof Arrayable) {
|
||||
$query->whereIn($key, $value);
|
||||
} else {
|
||||
$query->where($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// Now we are ready to execute the query to see if we have an user matching
|
||||
// the given credentials. If not, we will just return nulls and indicate
|
||||
// that there are no matching users for these given credential arrays.
|
||||
$user = $query->first();
|
||||
|
||||
return $this->getGenericUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the generic user.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @return \Illuminate\Auth\GenericUser|null
|
||||
*/
|
||||
protected function getGenericUser($user)
|
||||
{
|
||||
if (! is_null($user)) {
|
||||
return new GenericUser((array) $user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user against the given credentials.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validateCredentials(UserContract $user, array $credentials)
|
||||
{
|
||||
return $this->hasher->check(
|
||||
$credentials['password'], $user->getAuthPassword()
|
||||
);
|
||||
}
|
||||
}
|
||||
218
vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
vendored
Normal file
218
vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
||||
|
||||
class EloquentUserProvider implements UserProvider
|
||||
{
|
||||
/**
|
||||
* The hasher implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
protected $hasher;
|
||||
|
||||
/**
|
||||
* The Eloquent user model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Create a new database user provider.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
* @param string $model
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(HasherContract $hasher, $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->hasher = $hasher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by their unique identifier.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveById($identifier)
|
||||
{
|
||||
$model = $this->createModel();
|
||||
|
||||
return $this->newModelQuery($model)
|
||||
->where($model->getAuthIdentifierName(), $identifier)
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by their unique identifier and "remember me" token.
|
||||
*
|
||||
* @param mixed $identifier
|
||||
* @param string $token
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveByToken($identifier, $token)
|
||||
{
|
||||
$model = $this->createModel();
|
||||
|
||||
$retrievedModel = $this->newModelQuery($model)->where(
|
||||
$model->getAuthIdentifierName(), $identifier
|
||||
)->first();
|
||||
|
||||
if (! $retrievedModel) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rememberToken = $retrievedModel->getRememberToken();
|
||||
|
||||
return $rememberToken && hash_equals($rememberToken, $token)
|
||||
? $retrievedModel : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the "remember me" token for the given user in storage.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|\Illuminate\Database\Eloquent\Model $user
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function updateRememberToken(UserContract $user, $token)
|
||||
{
|
||||
$user->setRememberToken($token);
|
||||
|
||||
$timestamps = $user->timestamps;
|
||||
|
||||
$user->timestamps = false;
|
||||
|
||||
$user->save();
|
||||
|
||||
$user->timestamps = $timestamps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a user by the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function retrieveByCredentials(array $credentials)
|
||||
{
|
||||
if (empty($credentials) ||
|
||||
(count($credentials) === 1 &&
|
||||
array_key_exists('password', $credentials))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// First we will add each credential element to the query as a where clause.
|
||||
// Then we can execute the query and, if we found a user, return it in a
|
||||
// Eloquent User "model" that will be utilized by the Guard instances.
|
||||
$query = $this->newModelQuery();
|
||||
|
||||
foreach ($credentials as $key => $value) {
|
||||
if (Str::contains($key, 'password')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($value) || $value instanceof Arrayable) {
|
||||
$query->whereIn($key, $value);
|
||||
} else {
|
||||
$query->where($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user against the given credentials.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validateCredentials(UserContract $user, array $credentials)
|
||||
{
|
||||
$plain = $credentials['password'];
|
||||
|
||||
return $this->hasher->check($plain, $user->getAuthPassword());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a new query builder for the model instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model|null $model
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
protected function newModelQuery($model = null)
|
||||
{
|
||||
return is_null($model)
|
||||
? $this->createModel()->newQuery()
|
||||
: $model->newQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the model.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public function createModel()
|
||||
{
|
||||
$class = '\\'.ltrim($this->model, '\\');
|
||||
|
||||
return new $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hasher implementation.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
public function getHasher()
|
||||
{
|
||||
return $this->hasher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the hasher implementation.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
* @return $this
|
||||
*/
|
||||
public function setHasher(HasherContract $hasher)
|
||||
{
|
||||
$this->hasher = $hasher;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the Eloquent user model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModel()
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the Eloquent user model.
|
||||
*
|
||||
* @param string $model
|
||||
* @return $this
|
||||
*/
|
||||
public function setModel($model)
|
||||
{
|
||||
$this->model = $model;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
42
vendor/laravel/framework/src/Illuminate/Auth/Events/Attempting.php
vendored
Normal file
42
vendor/laravel/framework/src/Illuminate/Auth/Events/Attempting.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
class Attempting
|
||||
{
|
||||
/**
|
||||
* The authentication guard name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $guard;
|
||||
|
||||
/**
|
||||
* The credentials for the user.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $credentials;
|
||||
|
||||
/**
|
||||
* Indicates if the user should be "remembered".
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $remember;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $guard
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($guard, $credentials, $remember)
|
||||
{
|
||||
$this->guard = $guard;
|
||||
$this->remember = $remember;
|
||||
$this->credentials = $credentials;
|
||||
}
|
||||
}
|
||||
37
vendor/laravel/framework/src/Illuminate/Auth/Events/Authenticated.php
vendored
Normal file
37
vendor/laravel/framework/src/Illuminate/Auth/Events/Authenticated.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Authenticated
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The authentication guard name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $guard;
|
||||
|
||||
/**
|
||||
* The authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $guard
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($guard, $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->guard = $guard;
|
||||
}
|
||||
}
|
||||
42
vendor/laravel/framework/src/Illuminate/Auth/Events/Failed.php
vendored
Normal file
42
vendor/laravel/framework/src/Illuminate/Auth/Events/Failed.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
class Failed
|
||||
{
|
||||
/**
|
||||
* The authentication guard name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $guard;
|
||||
|
||||
/**
|
||||
* The user the attempter was trying to authenticate as.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* The credentials provided by the attempter.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $credentials;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $guard
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @param array $credentials
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($guard, $user, $credentials)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->guard = $guard;
|
||||
$this->credentials = $credentials;
|
||||
}
|
||||
}
|
||||
26
vendor/laravel/framework/src/Illuminate/Auth/Events/Lockout.php
vendored
Normal file
26
vendor/laravel/framework/src/Illuminate/Auth/Events/Lockout.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Lockout
|
||||
{
|
||||
/**
|
||||
* The throttled request.
|
||||
*
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
public $request;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
}
|
||||
}
|
||||
46
vendor/laravel/framework/src/Illuminate/Auth/Events/Login.php
vendored
Normal file
46
vendor/laravel/framework/src/Illuminate/Auth/Events/Login.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Login
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The authentication guard name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $guard;
|
||||
|
||||
/**
|
||||
* The authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Indicates if the user should be "remembered".
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $remember;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $guard
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param bool $remember
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($guard, $user, $remember)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->guard = $guard;
|
||||
$this->remember = $remember;
|
||||
}
|
||||
}
|
||||
37
vendor/laravel/framework/src/Illuminate/Auth/Events/Logout.php
vendored
Normal file
37
vendor/laravel/framework/src/Illuminate/Auth/Events/Logout.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Logout
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The authentication guard name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $guard;
|
||||
|
||||
/**
|
||||
* The authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $guard
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($guard, $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->guard = $guard;
|
||||
}
|
||||
}
|
||||
37
vendor/laravel/framework/src/Illuminate/Auth/Events/OtherDeviceLogout.php
vendored
Normal file
37
vendor/laravel/framework/src/Illuminate/Auth/Events/OtherDeviceLogout.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class OtherDeviceLogout
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The authentication guard name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $guard;
|
||||
|
||||
/**
|
||||
* The authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $guard
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($guard, $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->guard = $guard;
|
||||
}
|
||||
}
|
||||
28
vendor/laravel/framework/src/Illuminate/Auth/Events/PasswordReset.php
vendored
Normal file
28
vendor/laravel/framework/src/Illuminate/Auth/Events/PasswordReset.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class PasswordReset
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
28
vendor/laravel/framework/src/Illuminate/Auth/Events/Registered.php
vendored
Normal file
28
vendor/laravel/framework/src/Illuminate/Auth/Events/Registered.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Registered
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
28
vendor/laravel/framework/src/Illuminate/Auth/Events/Verified.php
vendored
Normal file
28
vendor/laravel/framework/src/Illuminate/Auth/Events/Verified.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Verified
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The verified user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\MustVerifyEmail
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\MustVerifyEmail $user
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
134
vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php
vendored
Normal file
134
vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
||||
|
||||
class GenericUser implements UserContract
|
||||
{
|
||||
/**
|
||||
* All of the user's attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes;
|
||||
|
||||
/**
|
||||
* Create a new generic User object.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $attributes)
|
||||
{
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the unique identifier for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthIdentifierName()
|
||||
{
|
||||
return 'id';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unique identifier for the user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthIdentifier()
|
||||
{
|
||||
$name = $this->getAuthIdentifierName();
|
||||
|
||||
return $this->attributes[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthPassword()
|
||||
{
|
||||
return $this->attributes['password'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the "remember me" token value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberToken()
|
||||
{
|
||||
return $this->attributes[$this->getRememberTokenName()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the "remember me" token value.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setRememberToken($value)
|
||||
{
|
||||
$this->attributes[$this->getRememberTokenName()] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the column name for the "remember me" token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRememberTokenName()
|
||||
{
|
||||
return 'remember_token';
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically access the user's attributes.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($key)
|
||||
{
|
||||
return $this->attributes[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically set an attribute on the user.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function __set($key, $value)
|
||||
{
|
||||
$this->attributes[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically check if a value is set on the user.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return isset($this->attributes[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically unset a value on the user.
|
||||
*
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
unset($this->attributes[$key]);
|
||||
}
|
||||
}
|
||||
118
vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php
vendored
Normal file
118
vendor/laravel/framework/src/Illuminate/Auth/GuardHelpers.php
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
|
||||
/**
|
||||
* These methods are typically the same across all guards.
|
||||
*/
|
||||
trait GuardHelpers
|
||||
{
|
||||
/**
|
||||
* The currently authenticated user.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* The user provider implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\UserProvider
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* Determine if current user is authenticated. If not, throw an exception.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable
|
||||
*
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
*/
|
||||
public function authenticate()
|
||||
{
|
||||
if (! is_null($user = $this->user())) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
throw new AuthenticationException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the guard has a user instance.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasUser()
|
||||
{
|
||||
return ! is_null($this->user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current user is authenticated.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
return ! is_null($this->user());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current user is a guest.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function guest()
|
||||
{
|
||||
return ! $this->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID for the currently authenticated user.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function id()
|
||||
{
|
||||
if ($this->user()) {
|
||||
return $this->user()->getAuthIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return $this
|
||||
*/
|
||||
public function setUser(AuthenticatableContract $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user provider used by the guard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\UserProvider
|
||||
*/
|
||||
public function getProvider()
|
||||
{
|
||||
return $this->provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the user provider used by the guard.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\UserProvider $provider
|
||||
* @return void
|
||||
*/
|
||||
public function setProvider(UserProvider $provider)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
}
|
||||
}
|
||||
21
vendor/laravel/framework/src/Illuminate/Auth/LICENSE.md
vendored
Normal file
21
vendor/laravel/framework/src/Illuminate/Auth/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Taylor Otwell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
22
vendor/laravel/framework/src/Illuminate/Auth/Listeners/SendEmailVerificationNotification.php
vendored
Normal file
22
vendor/laravel/framework/src/Illuminate/Auth/Listeners/SendEmailVerificationNotification.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Listeners;
|
||||
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
|
||||
class SendEmailVerificationNotification
|
||||
{
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param \Illuminate\Auth\Events\Registered $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Registered $event)
|
||||
{
|
||||
if ($event->user instanceof MustVerifyEmail && ! $event->user->hasVerifiedEmail()) {
|
||||
$event->user->sendEmailVerificationNotification();
|
||||
}
|
||||
}
|
||||
}
|
||||
82
vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php
vendored
Normal file
82
vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Contracts\Auth\Factory as Auth;
|
||||
|
||||
class Authenticate
|
||||
{
|
||||
/**
|
||||
* The authentication factory instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Factory
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new middleware instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Factory $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Auth $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string[] ...$guards
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
*/
|
||||
public function handle($request, Closure $next, ...$guards)
|
||||
{
|
||||
$this->authenticate($request, $guards);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is logged in to any of the given guards.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param array $guards
|
||||
* @return void
|
||||
*
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
*/
|
||||
protected function authenticate($request, array $guards)
|
||||
{
|
||||
if (empty($guards)) {
|
||||
$guards = [null];
|
||||
}
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if ($this->auth->guard($guard)->check()) {
|
||||
return $this->auth->shouldUse($guard);
|
||||
}
|
||||
}
|
||||
|
||||
throw new AuthenticationException(
|
||||
'Unauthenticated.', $guards, $this->redirectTo($request)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
45
vendor/laravel/framework/src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php
vendored
Normal file
45
vendor/laravel/framework/src/Illuminate/Auth/Middleware/AuthenticateWithBasicAuth.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Factory as AuthFactory;
|
||||
|
||||
class AuthenticateWithBasicAuth
|
||||
{
|
||||
/**
|
||||
* The guard factory instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Factory
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new middleware instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Factory $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(AuthFactory $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @param string|null $field
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null, $field = null)
|
||||
{
|
||||
$this->auth->guard($guard)->basic($field ?: 'email');
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
93
vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authorize.php
vendored
Normal file
93
vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authorize.php
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Contracts\Auth\Access\Gate;
|
||||
|
||||
class Authorize
|
||||
{
|
||||
/**
|
||||
* The gate instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Access\Gate
|
||||
*/
|
||||
protected $gate;
|
||||
|
||||
/**
|
||||
* Create a new middleware instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Gate $gate)
|
||||
{
|
||||
$this->gate = $gate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string $ability
|
||||
* @param array|null ...$models
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Illuminate\Auth\AuthenticationException
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function handle($request, Closure $next, $ability, ...$models)
|
||||
{
|
||||
$this->gate->authorize($ability, $this->getGateArguments($request, $models));
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the arguments parameter for the gate.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param array|null $models
|
||||
* @return array|string|\Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
protected function getGateArguments($request, $models)
|
||||
{
|
||||
if (is_null($models)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return collect($models)->map(function ($model) use ($request) {
|
||||
return $model instanceof Model ? $model : $this->getModel($request, $model);
|
||||
})->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model to authorize.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $model
|
||||
* @return \Illuminate\Database\Eloquent\Model|string
|
||||
*/
|
||||
protected function getModel($request, $model)
|
||||
{
|
||||
if ($this->isClassName($model)) {
|
||||
return trim($model);
|
||||
} else {
|
||||
return $request->route($model, null) ?:
|
||||
((preg_match("/^['\"](.*)['\"]$/", trim($model), $matches)) ? $matches[1] : null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given string looks like a fully qualified class name.
|
||||
*
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function isClassName($value)
|
||||
{
|
||||
return strpos($value, '\\') !== false;
|
||||
}
|
||||
}
|
||||
31
vendor/laravel/framework/src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php
vendored
Normal file
31
vendor/laravel/framework/src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
|
||||
class EnsureEmailIsVerified
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $redirectToRoute
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle($request, Closure $next, $redirectToRoute = null)
|
||||
{
|
||||
if (! $request->user() ||
|
||||
($request->user() instanceof MustVerifyEmail &&
|
||||
! $request->user()->hasVerifiedEmail())) {
|
||||
return $request->expectsJson()
|
||||
? abort(403, 'Your email address is not verified.')
|
||||
: Redirect::route($redirectToRoute ?: 'verification.notice');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
38
vendor/laravel/framework/src/Illuminate/Auth/MustVerifyEmail.php
vendored
Normal file
38
vendor/laravel/framework/src/Illuminate/Auth/MustVerifyEmail.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
trait MustVerifyEmail
|
||||
{
|
||||
/**
|
||||
* Determine if the user has verified their email address.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasVerifiedEmail()
|
||||
{
|
||||
return ! is_null($this->email_verified_at);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the given user's email as verified.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function markEmailAsVerified()
|
||||
{
|
||||
return $this->forceFill([
|
||||
'email_verified_at' => $this->freshTimestamp(),
|
||||
])->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the email verification notification.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sendEmailVerificationNotification()
|
||||
{
|
||||
$this->notify(new Notifications\VerifyEmail);
|
||||
}
|
||||
}
|
||||
77
vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php
vendored
Normal file
77
vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Notifications;
|
||||
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class ResetPassword extends Notification
|
||||
{
|
||||
/**
|
||||
* The password reset token.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $token;
|
||||
|
||||
/**
|
||||
* The callback that should be used to build the mail message.
|
||||
*
|
||||
* @var \Closure|null
|
||||
*/
|
||||
public static $toMailCallback;
|
||||
|
||||
/**
|
||||
* Create a notification instance.
|
||||
*
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($token)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array|string
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
if (static::$toMailCallback) {
|
||||
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
|
||||
}
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(Lang::getFromJson('Reset Password Notification'))
|
||||
->line(Lang::getFromJson('You are receiving this email because we received a password reset request for your account.'))
|
||||
->action(Lang::getFromJson('Reset Password'), url(config('app.url').route('password.reset', ['token' => $this->token, 'email' => $notifiable->getEmailForPasswordReset()], false)))
|
||||
->line(Lang::getFromJson('This password reset link will expire in :count minutes.', ['count' => config('auth.passwords.users.expire')]))
|
||||
->line(Lang::getFromJson('If you did not request a password reset, no further action is required.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that should be used when building the notification mail message.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return void
|
||||
*/
|
||||
public static function toMailUsing($callback)
|
||||
{
|
||||
static::$toMailCallback = $callback;
|
||||
}
|
||||
}
|
||||
78
vendor/laravel/framework/src/Illuminate/Auth/Notifications/VerifyEmail.php
vendored
Normal file
78
vendor/laravel/framework/src/Illuminate/Auth/Notifications/VerifyEmail.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Notifications;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class VerifyEmail extends Notification
|
||||
{
|
||||
/**
|
||||
* The callback that should be used to build the mail message.
|
||||
*
|
||||
* @var \Closure|null
|
||||
*/
|
||||
public static $toMailCallback;
|
||||
|
||||
/**
|
||||
* Get the notification's channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array|string
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$verificationUrl = $this->verificationUrl($notifiable);
|
||||
|
||||
if (static::$toMailCallback) {
|
||||
return call_user_func(static::$toMailCallback, $notifiable, $verificationUrl);
|
||||
}
|
||||
|
||||
return (new MailMessage)
|
||||
->subject(Lang::getFromJson('Verify Email Address'))
|
||||
->line(Lang::getFromJson('Please click the button below to verify your email address.'))
|
||||
->action(Lang::getFromJson('Verify Email Address'), $verificationUrl)
|
||||
->line(Lang::getFromJson('If you did not create an account, no further action is required.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the verification URL for the given notifiable.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return string
|
||||
*/
|
||||
protected function verificationUrl($notifiable)
|
||||
{
|
||||
return URL::temporarySignedRoute(
|
||||
'verification.verify',
|
||||
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
|
||||
['id' => $notifiable->getKey()]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that should be used when building the notification mail message.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return void
|
||||
*/
|
||||
public static function toMailUsing($callback)
|
||||
{
|
||||
static::$toMailCallback = $callback;
|
||||
}
|
||||
}
|
||||
29
vendor/laravel/framework/src/Illuminate/Auth/Passwords/CanResetPassword.php
vendored
Normal file
29
vendor/laravel/framework/src/Illuminate/Auth/Passwords/CanResetPassword.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
|
||||
|
||||
trait CanResetPassword
|
||||
{
|
||||
/**
|
||||
* Get the e-mail address where password reset links are sent.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEmailForPasswordReset()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the password reset notification.
|
||||
*
|
||||
* @param string $token
|
||||
* @return void
|
||||
*/
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
$this->notify(new ResetPasswordNotification($token));
|
||||
}
|
||||
}
|
||||
204
vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
vendored
Normal file
204
vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
|
||||
class DatabaseTokenRepository implements TokenRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* The database connection instance.
|
||||
*
|
||||
* @var \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* The Hasher implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
protected $hasher;
|
||||
|
||||
/**
|
||||
* The token database table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table;
|
||||
|
||||
/**
|
||||
* The hashing key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $hashKey;
|
||||
|
||||
/**
|
||||
* The number of seconds a token should last.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $expires;
|
||||
|
||||
/**
|
||||
* Create a new token repository instance.
|
||||
*
|
||||
* @param \Illuminate\Database\ConnectionInterface $connection
|
||||
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
|
||||
* @param string $table
|
||||
* @param string $hashKey
|
||||
* @param int $expires
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ConnectionInterface $connection, HasherContract $hasher,
|
||||
$table, $hashKey, $expires = 60)
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->hasher = $hasher;
|
||||
$this->hashKey = $hashKey;
|
||||
$this->expires = $expires * 60;
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new token record.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return string
|
||||
*/
|
||||
public function create(CanResetPasswordContract $user)
|
||||
{
|
||||
$email = $user->getEmailForPasswordReset();
|
||||
|
||||
$this->deleteExisting($user);
|
||||
|
||||
// We will create a new, random token for the user so that we can e-mail them
|
||||
// a safe link to the password reset form. Then we will insert a record in
|
||||
// the database so that we can verify the token within the actual reset.
|
||||
$token = $this->createNewToken();
|
||||
|
||||
$this->getTable()->insert($this->getPayload($email, $token));
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all existing reset tokens from the database.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return int
|
||||
*/
|
||||
protected function deleteExisting(CanResetPasswordContract $user)
|
||||
{
|
||||
return $this->getTable()->where('email', $user->getEmailForPasswordReset())->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the record payload for the table.
|
||||
*
|
||||
* @param string $email
|
||||
* @param string $token
|
||||
* @return array
|
||||
*/
|
||||
protected function getPayload($email, $token)
|
||||
{
|
||||
return ['email' => $email, 'token' => $this->hasher->make($token), 'created_at' => new Carbon];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a token record exists and is valid.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @param string $token
|
||||
* @return bool
|
||||
*/
|
||||
public function exists(CanResetPasswordContract $user, $token)
|
||||
{
|
||||
$record = (array) $this->getTable()->where(
|
||||
'email', $user->getEmailForPasswordReset()
|
||||
)->first();
|
||||
|
||||
return $record &&
|
||||
! $this->tokenExpired($record['created_at']) &&
|
||||
$this->hasher->check($token, $record['token']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the token has expired.
|
||||
*
|
||||
* @param string $createdAt
|
||||
* @return bool
|
||||
*/
|
||||
protected function tokenExpired($createdAt)
|
||||
{
|
||||
return Carbon::parse($createdAt)->addSeconds($this->expires)->isPast();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a token record by user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return void
|
||||
*/
|
||||
public function delete(CanResetPasswordContract $user)
|
||||
{
|
||||
$this->deleteExisting($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete expired tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteExpired()
|
||||
{
|
||||
$expiredAt = Carbon::now()->subSeconds($this->expires);
|
||||
|
||||
$this->getTable()->where('created_at', '<', $expiredAt)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new token for the user.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function createNewToken()
|
||||
{
|
||||
return hash_hmac('sha256', Str::random(40), $this->hashKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the database connection instance.
|
||||
*
|
||||
* @return \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin a new database query against the table.
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder
|
||||
*/
|
||||
protected function getTable()
|
||||
{
|
||||
return $this->connection->table($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hasher instance.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
public function getHasher()
|
||||
{
|
||||
return $this->hasher;
|
||||
}
|
||||
}
|
||||
242
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
vendored
Normal file
242
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBroker.php
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Arr;
|
||||
use UnexpectedValueException;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Auth\PasswordBroker as PasswordBrokerContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
|
||||
class PasswordBroker implements PasswordBrokerContract
|
||||
{
|
||||
/**
|
||||
* The password token repository.
|
||||
*
|
||||
* @var \Illuminate\Auth\Passwords\TokenRepositoryInterface
|
||||
*/
|
||||
protected $tokens;
|
||||
|
||||
/**
|
||||
* The user provider implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\UserProvider
|
||||
*/
|
||||
protected $users;
|
||||
|
||||
/**
|
||||
* The custom password validator callback.
|
||||
*
|
||||
* @var \Closure
|
||||
*/
|
||||
protected $passwordValidator;
|
||||
|
||||
/**
|
||||
* Create a new password broker instance.
|
||||
*
|
||||
* @param \Illuminate\Auth\Passwords\TokenRepositoryInterface $tokens
|
||||
* @param \Illuminate\Contracts\Auth\UserProvider $users
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TokenRepositoryInterface $tokens,
|
||||
UserProvider $users)
|
||||
{
|
||||
$this->users = $users;
|
||||
$this->tokens = $tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a password reset link to a user.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return string
|
||||
*/
|
||||
public function sendResetLink(array $credentials)
|
||||
{
|
||||
// First we will check to see if we found a user at the given credentials and
|
||||
// if we did not we will redirect back to this current URI with a piece of
|
||||
// "flash" data in the session to indicate to the developers the errors.
|
||||
$user = $this->getUser($credentials);
|
||||
|
||||
if (is_null($user)) {
|
||||
return static::INVALID_USER;
|
||||
}
|
||||
|
||||
// Once we have the reset token, we are ready to send the message out to this
|
||||
// user with a link to reset their password. We will then redirect back to
|
||||
// the current URI having nothing set in the session to indicate errors.
|
||||
$user->sendPasswordResetNotification(
|
||||
$this->tokens->create($user)
|
||||
);
|
||||
|
||||
return static::RESET_LINK_SENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the password for the given token.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param \Closure $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function reset(array $credentials, Closure $callback)
|
||||
{
|
||||
// If the responses from the validate method is not a user instance, we will
|
||||
// assume that it is a redirect and simply return it from this method and
|
||||
// the user is properly redirected having an error message on the post.
|
||||
$user = $this->validateReset($credentials);
|
||||
|
||||
if (! $user instanceof CanResetPasswordContract) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
$password = $credentials['password'];
|
||||
|
||||
// Once the reset has been validated, we'll call the given callback with the
|
||||
// new password. This gives the user an opportunity to store the password
|
||||
// in their persistent storage. Then we'll delete the token and return.
|
||||
$callback($user, $password);
|
||||
|
||||
$this->tokens->delete($user);
|
||||
|
||||
return static::PASSWORD_RESET;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a password reset for the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return \Illuminate\Contracts\Auth\CanResetPassword|string
|
||||
*/
|
||||
protected function validateReset(array $credentials)
|
||||
{
|
||||
if (is_null($user = $this->getUser($credentials))) {
|
||||
return static::INVALID_USER;
|
||||
}
|
||||
|
||||
if (! $this->validateNewPassword($credentials)) {
|
||||
return static::INVALID_PASSWORD;
|
||||
}
|
||||
|
||||
if (! $this->tokens->exists($user, $credentials['token'])) {
|
||||
return static::INVALID_TOKEN;
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a custom password validator.
|
||||
*
|
||||
* @param \Closure $callback
|
||||
* @return void
|
||||
*/
|
||||
public function validator(Closure $callback)
|
||||
{
|
||||
$this->passwordValidator = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the passwords match for the request.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validateNewPassword(array $credentials)
|
||||
{
|
||||
if (isset($this->passwordValidator)) {
|
||||
[$password, $confirm] = [
|
||||
$credentials['password'],
|
||||
$credentials['password_confirmation'],
|
||||
];
|
||||
|
||||
return call_user_func(
|
||||
$this->passwordValidator, $credentials
|
||||
) && $password === $confirm;
|
||||
}
|
||||
|
||||
return $this->validatePasswordWithDefaults($credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the passwords are valid for the request.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
protected function validatePasswordWithDefaults(array $credentials)
|
||||
{
|
||||
[$password, $confirm] = [
|
||||
$credentials['password'],
|
||||
$credentials['password_confirmation'],
|
||||
];
|
||||
|
||||
return $password === $confirm && mb_strlen($password) >= 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user for the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return \Illuminate\Contracts\Auth\CanResetPassword|null
|
||||
*
|
||||
* @throws \UnexpectedValueException
|
||||
*/
|
||||
public function getUser(array $credentials)
|
||||
{
|
||||
$credentials = Arr::except($credentials, ['token']);
|
||||
|
||||
$user = $this->users->retrieveByCredentials($credentials);
|
||||
|
||||
if ($user && ! $user instanceof CanResetPasswordContract) {
|
||||
throw new UnexpectedValueException('User must implement CanResetPassword interface.');
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new password reset token for the given user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return string
|
||||
*/
|
||||
public function createToken(CanResetPasswordContract $user)
|
||||
{
|
||||
return $this->tokens->create($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete password reset tokens of the given user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return void
|
||||
*/
|
||||
public function deleteToken(CanResetPasswordContract $user)
|
||||
{
|
||||
$this->tokens->delete($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the given password reset token.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @param string $token
|
||||
* @return bool
|
||||
*/
|
||||
public function tokenExists(CanResetPasswordContract $user, $token)
|
||||
{
|
||||
return $this->tokens->exists($user, $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password reset token repository implementation.
|
||||
*
|
||||
* @return \Illuminate\Auth\Passwords\TokenRepositoryInterface
|
||||
*/
|
||||
public function getRepository()
|
||||
{
|
||||
return $this->tokens;
|
||||
}
|
||||
}
|
||||
145
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBrokerManager.php
vendored
Normal file
145
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordBrokerManager.php
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Contracts\Auth\PasswordBrokerFactory as FactoryContract;
|
||||
|
||||
/**
|
||||
* @mixin \Illuminate\Contracts\Auth\PasswordBroker
|
||||
*/
|
||||
class PasswordBrokerManager implements FactoryContract
|
||||
{
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* The array of created "drivers".
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $brokers = [];
|
||||
|
||||
/**
|
||||
* Create a new PasswordBroker manager instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get the broker from the local cache.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return \Illuminate\Contracts\Auth\PasswordBroker
|
||||
*/
|
||||
public function broker($name = null)
|
||||
{
|
||||
$name = $name ?: $this->getDefaultDriver();
|
||||
|
||||
return $this->brokers[$name] ?? ($this->brokers[$name] = $this->resolve($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given broker.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Auth\PasswordBroker
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function resolve($name)
|
||||
{
|
||||
$config = $this->getConfig($name);
|
||||
|
||||
if (is_null($config)) {
|
||||
throw new InvalidArgumentException("Password resetter [{$name}] is not defined.");
|
||||
}
|
||||
|
||||
// The password broker uses a token repository to validate tokens and send user
|
||||
// password e-mails, as well as validating that password reset process as an
|
||||
// aggregate service of sorts providing a convenient interface for resets.
|
||||
return new PasswordBroker(
|
||||
$this->createTokenRepository($config),
|
||||
$this->app['auth']->createUserProvider($config['provider'] ?? null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a token repository instance based on the given configuration.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Auth\Passwords\TokenRepositoryInterface
|
||||
*/
|
||||
protected function createTokenRepository(array $config)
|
||||
{
|
||||
$key = $this->app['config']['app.key'];
|
||||
|
||||
if (Str::startsWith($key, 'base64:')) {
|
||||
$key = base64_decode(substr($key, 7));
|
||||
}
|
||||
|
||||
$connection = $config['connection'] ?? null;
|
||||
|
||||
return new DatabaseTokenRepository(
|
||||
$this->app['db']->connection($connection),
|
||||
$this->app['hash'],
|
||||
$config['table'],
|
||||
$key,
|
||||
$config['expire']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password broker configuration.
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
protected function getConfig($name)
|
||||
{
|
||||
return $this->app['config']["auth.passwords.{$name}"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default password broker name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->app['config']['auth.defaults.passwords'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default password broker name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultDriver($name)
|
||||
{
|
||||
$this->app['config']['auth.defaults.passwords'] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
return $this->broker()->{$method}(...$parameters);
|
||||
}
|
||||
}
|
||||
45
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
vendored
Normal file
45
vendor/laravel/framework/src/Illuminate/Auth/Passwords/PasswordResetServiceProvider.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
|
||||
class PasswordResetServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->registerPasswordBroker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the password broker instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerPasswordBroker()
|
||||
{
|
||||
$this->app->singleton('auth.password', function ($app) {
|
||||
return new PasswordBrokerManager($app);
|
||||
});
|
||||
|
||||
$this->app->bind('auth.password.broker', function ($app) {
|
||||
return $app->make('auth.password')->broker();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return ['auth.password', 'auth.password.broker'];
|
||||
}
|
||||
}
|
||||
40
vendor/laravel/framework/src/Illuminate/Auth/Passwords/TokenRepositoryInterface.php
vendored
Normal file
40
vendor/laravel/framework/src/Illuminate/Auth/Passwords/TokenRepositoryInterface.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth\Passwords;
|
||||
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
|
||||
interface TokenRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Create a new token.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return string
|
||||
*/
|
||||
public function create(CanResetPasswordContract $user);
|
||||
|
||||
/**
|
||||
* Determine if a token record exists and is valid.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @param string $token
|
||||
* @return bool
|
||||
*/
|
||||
public function exists(CanResetPasswordContract $user, $token);
|
||||
|
||||
/**
|
||||
* Delete a token record.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
|
||||
* @return void
|
||||
*/
|
||||
public function delete(CanResetPasswordContract $user);
|
||||
|
||||
/**
|
||||
* Delete expired tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteExpired();
|
||||
}
|
||||
88
vendor/laravel/framework/src/Illuminate/Auth/Recaller.php
vendored
Normal file
88
vendor/laravel/framework/src/Illuminate/Auth/Recaller.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Recaller
|
||||
{
|
||||
/**
|
||||
* The "recaller" / "remember me" cookie string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $recaller;
|
||||
|
||||
/**
|
||||
* Create a new recaller instance.
|
||||
*
|
||||
* @param string $recaller
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($recaller)
|
||||
{
|
||||
$this->recaller = @unserialize($recaller, ['allowed_classes' => false]) ?: $recaller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user ID from the recaller.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function id()
|
||||
{
|
||||
return explode('|', $this->recaller, 3)[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the "remember token" token from the recaller.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function token()
|
||||
{
|
||||
return explode('|', $this->recaller, 3)[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the password from the recaller.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function hash()
|
||||
{
|
||||
return explode('|', $this->recaller, 3)[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the recaller is valid.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return $this->properString() && $this->hasAllSegments();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the recaller is an invalid string.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function properString()
|
||||
{
|
||||
return is_string($this->recaller) && Str::contains($this->recaller, '|');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the recaller has all segments.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasAllSegments()
|
||||
{
|
||||
$segments = explode('|', $this->recaller);
|
||||
|
||||
return count($segments) === 3 && trim($segments[0]) !== '' && trim($segments[1]) !== '';
|
||||
}
|
||||
}
|
||||
87
vendor/laravel/framework/src/Illuminate/Auth/RequestGuard.php
vendored
Normal file
87
vendor/laravel/framework/src/Illuminate/Auth/RequestGuard.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
|
||||
class RequestGuard implements Guard
|
||||
{
|
||||
use GuardHelpers, Macroable;
|
||||
|
||||
/**
|
||||
* The guard callback.
|
||||
*
|
||||
* @var callable
|
||||
*/
|
||||
protected $callback;
|
||||
|
||||
/**
|
||||
* The request instance.
|
||||
*
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Create a new authentication guard.
|
||||
*
|
||||
* @param callable $callback
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Contracts\Auth\UserProvider|null $provider
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(callable $callback, Request $request, UserProvider $provider = null)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->callback = $callback;
|
||||
$this->provider = $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently authenticated user.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
// If we've already retrieved the user for the current request we can just
|
||||
// return it back immediately. We do not want to fetch the user data on
|
||||
// every call to this method because that would be tremendously slow.
|
||||
if (! is_null($this->user)) {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
return $this->user = call_user_func(
|
||||
$this->callback, $this->request, $this->getProvider()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user's credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validate(array $credentials = [])
|
||||
{
|
||||
return ! is_null((new static(
|
||||
$this->callback, $credentials['request'], $this->getProvider()
|
||||
))->user());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current request instance.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequest(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
801
vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php
vendored
Normal file
801
vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php
vendored
Normal file
@@ -0,0 +1,801 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use RuntimeException;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use Illuminate\Contracts\Session\Session;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Illuminate\Contracts\Auth\SupportsBasicAuth;
|
||||
use Illuminate\Contracts\Cookie\QueueingFactory as CookieJar;
|
||||
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
|
||||
class SessionGuard implements StatefulGuard, SupportsBasicAuth
|
||||
{
|
||||
use GuardHelpers, Macroable;
|
||||
|
||||
/**
|
||||
* The name of the Guard. Typically "session".
|
||||
*
|
||||
* Corresponds to guard name in authentication configuration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The user we last attempted to retrieve.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
protected $lastAttempted;
|
||||
|
||||
/**
|
||||
* Indicates if the user was authenticated via a recaller cookie.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $viaRemember = false;
|
||||
|
||||
/**
|
||||
* The session used by the guard.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Session\Session
|
||||
*/
|
||||
protected $session;
|
||||
|
||||
/**
|
||||
* The Illuminate cookie creator service.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Cookie\QueueingFactory
|
||||
*/
|
||||
protected $cookie;
|
||||
|
||||
/**
|
||||
* The request instance.
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* The event dispatcher instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
protected $events;
|
||||
|
||||
/**
|
||||
* Indicates if the logout method has been called.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $loggedOut = false;
|
||||
|
||||
/**
|
||||
* Indicates if a token user retrieval has been attempted.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $recallAttempted = false;
|
||||
|
||||
/**
|
||||
* Create a new authentication guard.
|
||||
*
|
||||
* @param string $name
|
||||
* @param \Illuminate\Contracts\Auth\UserProvider $provider
|
||||
* @param \Illuminate\Contracts\Session\Session $session
|
||||
* @param \Symfony\Component\HttpFoundation\Request|null $request
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name,
|
||||
UserProvider $provider,
|
||||
Session $session,
|
||||
Request $request = null)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->session = $session;
|
||||
$this->request = $request;
|
||||
$this->provider = $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently authenticated user.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
if ($this->loggedOut) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we've already retrieved the user for the current request we can just
|
||||
// return it back immediately. We do not want to fetch the user data on
|
||||
// every call to this method because that would be tremendously slow.
|
||||
if (! is_null($this->user)) {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
$id = $this->session->get($this->getName());
|
||||
|
||||
// First we will try to load the user using the identifier in the session if
|
||||
// one exists. Otherwise we will check for a "remember me" cookie in this
|
||||
// request, and if one exists, attempt to retrieve the user using that.
|
||||
if (! is_null($id) && $this->user = $this->provider->retrieveById($id)) {
|
||||
$this->fireAuthenticatedEvent($this->user);
|
||||
}
|
||||
|
||||
// If the user is null, but we decrypt a "recaller" cookie we can attempt to
|
||||
// pull the user data on that cookie which serves as a remember cookie on
|
||||
// the application. Once we have a user we can return it to the caller.
|
||||
if (is_null($this->user) && ! is_null($recaller = $this->recaller())) {
|
||||
$this->user = $this->userFromRecaller($recaller);
|
||||
|
||||
if ($this->user) {
|
||||
$this->updateSession($this->user->getAuthIdentifier());
|
||||
|
||||
$this->fireLoginEvent($this->user, true);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pull a user from the repository by its "remember me" cookie token.
|
||||
*
|
||||
* @param \Illuminate\Auth\Recaller $recaller
|
||||
* @return mixed
|
||||
*/
|
||||
protected function userFromRecaller($recaller)
|
||||
{
|
||||
if (! $recaller->valid() || $this->recallAttempted) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the user is null, but we decrypt a "recaller" cookie we can attempt to
|
||||
// pull the user data on that cookie which serves as a remember cookie on
|
||||
// the application. Once we have a user we can return it to the caller.
|
||||
$this->recallAttempted = true;
|
||||
|
||||
$this->viaRemember = ! is_null($user = $this->provider->retrieveByToken(
|
||||
$recaller->id(), $recaller->token()
|
||||
));
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the decrypted recaller cookie for the request.
|
||||
*
|
||||
* @return \Illuminate\Auth\Recaller|null
|
||||
*/
|
||||
protected function recaller()
|
||||
{
|
||||
if (is_null($this->request)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($recaller = $this->request->cookies->get($this->getRecallerName())) {
|
||||
return new Recaller($recaller);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID for the currently authenticated user.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function id()
|
||||
{
|
||||
if ($this->loggedOut) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->user()
|
||||
? $this->user()->getAuthIdentifier()
|
||||
: $this->session->get($this->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a user into the application without sessions or cookies.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function once(array $credentials = [])
|
||||
{
|
||||
$this->fireAttemptEvent($credentials);
|
||||
|
||||
if ($this->validate($credentials)) {
|
||||
$this->setUser($this->lastAttempted);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given user ID into the application without sessions or cookies.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|false
|
||||
*/
|
||||
public function onceUsingId($id)
|
||||
{
|
||||
if (! is_null($user = $this->provider->retrieveById($id))) {
|
||||
$this->setUser($user);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user's credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validate(array $credentials = [])
|
||||
{
|
||||
$this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);
|
||||
|
||||
return $this->hasValidCredentials($user, $credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate using HTTP Basic Auth.
|
||||
*
|
||||
* @param string $field
|
||||
* @param array $extraConditions
|
||||
* @return \Symfony\Component\HttpFoundation\Response|null
|
||||
*/
|
||||
public function basic($field = 'email', $extraConditions = [])
|
||||
{
|
||||
if ($this->check()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If a username is set on the HTTP basic request, we will return out without
|
||||
// interrupting the request lifecycle. Otherwise, we'll need to generate a
|
||||
// request indicating that the given credentials were invalid for login.
|
||||
if ($this->attemptBasic($this->getRequest(), $field, $extraConditions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->failedBasicResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a stateless HTTP Basic login attempt.
|
||||
*
|
||||
* @param string $field
|
||||
* @param array $extraConditions
|
||||
* @return \Symfony\Component\HttpFoundation\Response|null
|
||||
*/
|
||||
public function onceBasic($field = 'email', $extraConditions = [])
|
||||
{
|
||||
$credentials = $this->basicCredentials($this->getRequest(), $field);
|
||||
|
||||
if (! $this->once(array_merge($credentials, $extraConditions))) {
|
||||
return $this->failedBasicResponse();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate using basic authentication.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param string $field
|
||||
* @param array $extraConditions
|
||||
* @return bool
|
||||
*/
|
||||
protected function attemptBasic(Request $request, $field, $extraConditions = [])
|
||||
{
|
||||
if (! $request->getUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->attempt(array_merge(
|
||||
$this->basicCredentials($request, $field), $extraConditions
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the credential array for a HTTP Basic request.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
protected function basicCredentials(Request $request, $field)
|
||||
{
|
||||
return [$field => $request->getUser(), 'password' => $request->getPassword()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response for basic authentication.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException
|
||||
*/
|
||||
protected function failedBasicResponse()
|
||||
{
|
||||
throw new UnauthorizedHttpException('Basic', 'Invalid credentials.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate a user using the given credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
* @return bool
|
||||
*/
|
||||
public function attempt(array $credentials = [], $remember = false)
|
||||
{
|
||||
$this->fireAttemptEvent($credentials, $remember);
|
||||
|
||||
$this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);
|
||||
|
||||
// If an implementation of UserInterface was returned, we'll ask the provider
|
||||
// to validate the user against the given credentials, and if they are in
|
||||
// fact valid we'll log the users into the application and return true.
|
||||
if ($this->hasValidCredentials($user, $credentials)) {
|
||||
$this->login($user, $remember);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the authentication attempt fails we will fire an event so that the user
|
||||
// may be notified of any suspicious attempts to access their account from
|
||||
// an unrecognized user. A developer may listen to this event as needed.
|
||||
$this->fireFailedEvent($user, $credentials);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user matches the credentials.
|
||||
*
|
||||
* @param mixed $user
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasValidCredentials($user, $credentials)
|
||||
{
|
||||
return ! is_null($user) && $this->provider->validateCredentials($user, $credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the given user ID into the application.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @param bool $remember
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|false
|
||||
*/
|
||||
public function loginUsingId($id, $remember = false)
|
||||
{
|
||||
if (! is_null($user = $this->provider->retrieveById($id))) {
|
||||
$this->login($user, $remember);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a user into the application.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param bool $remember
|
||||
* @return void
|
||||
*/
|
||||
public function login(AuthenticatableContract $user, $remember = false)
|
||||
{
|
||||
$this->updateSession($user->getAuthIdentifier());
|
||||
|
||||
// If the user should be permanently "remembered" by the application we will
|
||||
// queue a permanent cookie that contains the encrypted copy of the user
|
||||
// identifier. We will then decrypt this later to retrieve the users.
|
||||
if ($remember) {
|
||||
$this->ensureRememberTokenIsSet($user);
|
||||
|
||||
$this->queueRecallerCookie($user);
|
||||
}
|
||||
|
||||
// If we have an event dispatcher instance set we will fire an event so that
|
||||
// any listeners will hook into the authentication events and run actions
|
||||
// based on the login and logout events fired from the guard instances.
|
||||
$this->fireLoginEvent($user, $remember);
|
||||
|
||||
$this->setUser($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the session with the given ID.
|
||||
*
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
protected function updateSession($id)
|
||||
{
|
||||
$this->session->put($this->getName(), $id);
|
||||
|
||||
$this->session->migrate(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new "remember me" token for the user if one doesn't already exist.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
protected function ensureRememberTokenIsSet(AuthenticatableContract $user)
|
||||
{
|
||||
if (empty($user->getRememberToken())) {
|
||||
$this->cycleRememberToken($user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue the recaller cookie into the cookie jar.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
protected function queueRecallerCookie(AuthenticatableContract $user)
|
||||
{
|
||||
$this->getCookieJar()->queue($this->createRecaller(
|
||||
$user->getAuthIdentifier().'|'.$user->getRememberToken().'|'.$user->getAuthPassword()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a "remember me" cookie for a given ID.
|
||||
*
|
||||
* @param string $value
|
||||
* @return \Symfony\Component\HttpFoundation\Cookie
|
||||
*/
|
||||
protected function createRecaller($value)
|
||||
{
|
||||
return $this->getCookieJar()->forever($this->getRecallerName(), $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
$user = $this->user();
|
||||
|
||||
// If we have an event dispatcher instance, we can fire off the logout event
|
||||
// so any further processing can be done. This allows the developer to be
|
||||
// listening for anytime a user signs out of this application manually.
|
||||
$this->clearUserDataFromStorage();
|
||||
|
||||
if (! is_null($this->user) && ! empty($user->getRememberToken())) {
|
||||
$this->cycleRememberToken($user);
|
||||
}
|
||||
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\Logout($this->name, $user));
|
||||
}
|
||||
|
||||
// Once we have fired the logout event we will clear the users out of memory
|
||||
// so they are no longer available as the user is no longer considered as
|
||||
// being signed into this application and should not be available here.
|
||||
$this->user = null;
|
||||
|
||||
$this->loggedOut = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the user data from the session and cookies.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function clearUserDataFromStorage()
|
||||
{
|
||||
$this->session->remove($this->getName());
|
||||
|
||||
if (! is_null($this->recaller())) {
|
||||
$this->getCookieJar()->queue($this->getCookieJar()
|
||||
->forget($this->getRecallerName()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the "remember me" token for the user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
protected function cycleRememberToken(AuthenticatableContract $user)
|
||||
{
|
||||
$user->setRememberToken($token = Str::random(60));
|
||||
|
||||
$this->provider->updateRememberToken($user, $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate other sessions for the current user.
|
||||
*
|
||||
* The application must be using the AuthenticateSession middleware.
|
||||
*
|
||||
* @param string $password
|
||||
* @param string $attribute
|
||||
* @return bool|null
|
||||
*/
|
||||
public function logoutOtherDevices($password, $attribute = 'password')
|
||||
{
|
||||
if (! $this->user()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$result = tap($this->user()->forceFill([
|
||||
$attribute => Hash::make($password),
|
||||
]))->save();
|
||||
|
||||
if ($this->recaller() ||
|
||||
$this->getCookieJar()->hasQueued($this->getRecallerName())) {
|
||||
$this->queueRecallerCookie($this->user());
|
||||
}
|
||||
|
||||
$this->fireOtherDeviceLogoutEvent($this->user());
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an authentication attempt event listener.
|
||||
*
|
||||
* @param mixed $callback
|
||||
* @return void
|
||||
*/
|
||||
public function attempting($callback)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->listen(Events\Attempting::class, $callback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the attempt event with the arguments.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
* @return void
|
||||
*/
|
||||
protected function fireAttemptEvent(array $credentials, $remember = false)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\Attempting(
|
||||
$this->name, $credentials, $remember
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the login event if the dispatcher is set.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param bool $remember
|
||||
* @return void
|
||||
*/
|
||||
protected function fireLoginEvent($user, $remember = false)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\Login(
|
||||
$this->name, $user, $remember
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the authenticated event if the dispatcher is set.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
protected function fireAuthenticatedEvent($user)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\Authenticated(
|
||||
$this->name, $user
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the other device logout event if the dispatcher is set.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return void
|
||||
*/
|
||||
protected function fireOtherDeviceLogoutEvent($user)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\OtherDeviceLogout(
|
||||
$this->name, $user
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire the failed authentication attempt event with the given arguments.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
|
||||
* @param array $credentials
|
||||
* @return void
|
||||
*/
|
||||
protected function fireFailedEvent($user, array $credentials)
|
||||
{
|
||||
if (isset($this->events)) {
|
||||
$this->events->dispatch(new Events\Failed(
|
||||
$this->name, $user, $credentials
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last user we attempted to authenticate.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable
|
||||
*/
|
||||
public function getLastAttempted()
|
||||
{
|
||||
return $this->lastAttempted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a unique identifier for the auth session value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'login_'.$this->name.'_'.sha1(static::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the cookie used to store the "recaller".
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRecallerName()
|
||||
{
|
||||
return 'remember_'.$this->name.'_'.sha1(static::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user was authenticated via "remember me" cookie.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function viaRemember()
|
||||
{
|
||||
return $this->viaRemember;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cookie creator instance used by the guard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Cookie\QueueingFactory
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function getCookieJar()
|
||||
{
|
||||
if (! isset($this->cookie)) {
|
||||
throw new RuntimeException('Cookie jar has not been set.');
|
||||
}
|
||||
|
||||
return $this->cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cookie creator instance used by the guard.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Cookie\QueueingFactory $cookie
|
||||
* @return void
|
||||
*/
|
||||
public function setCookieJar(CookieJar $cookie)
|
||||
{
|
||||
$this->cookie = $cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event dispatcher instance.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the event dispatcher instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
* @return void
|
||||
*/
|
||||
public function setDispatcher(Dispatcher $events)
|
||||
{
|
||||
$this->events = $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session store used by the guard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Session\Session
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the currently cached user.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return $this
|
||||
*/
|
||||
public function setUser(AuthenticatableContract $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
$this->loggedOut = false;
|
||||
|
||||
$this->fireAuthenticatedEvent($user);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current request instance.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
public function getRequest()
|
||||
{
|
||||
return $this->request ?: Request::createFromGlobals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current request instance.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequest(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
149
vendor/laravel/framework/src/Illuminate/Auth/TokenGuard.php
vendored
Normal file
149
vendor/laravel/framework/src/Illuminate/Auth/TokenGuard.php
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
|
||||
class TokenGuard implements Guard
|
||||
{
|
||||
use GuardHelpers;
|
||||
|
||||
/**
|
||||
* The request instance.
|
||||
*
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* The name of the query string item from the request containing the API token.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $inputKey;
|
||||
|
||||
/**
|
||||
* The name of the token "column" in persistent storage.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $storageKey;
|
||||
|
||||
/**
|
||||
* Indicates if the API token is hashed in storage.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $hash = false;
|
||||
|
||||
/**
|
||||
* Create a new authentication guard.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\UserProvider $provider
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $inputKey
|
||||
* @param string $storageKey
|
||||
* @param bool $hash
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
UserProvider $provider,
|
||||
Request $request,
|
||||
$inputKey = 'api_token',
|
||||
$storageKey = 'api_token',
|
||||
$hash = false)
|
||||
{
|
||||
$this->hash = $hash;
|
||||
$this->request = $request;
|
||||
$this->provider = $provider;
|
||||
$this->inputKey = $inputKey;
|
||||
$this->storageKey = $storageKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently authenticated user.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
// If we've already retrieved the user for the current request we can just
|
||||
// return it back immediately. We do not want to fetch the user data on
|
||||
// every call to this method because that would be tremendously slow.
|
||||
if (! is_null($this->user)) {
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
$user = null;
|
||||
|
||||
$token = $this->getTokenForRequest();
|
||||
|
||||
if (! empty($token)) {
|
||||
$user = $this->provider->retrieveByCredentials([
|
||||
$this->storageKey => $this->hash ? hash('sha256', $token) : $token,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->user = $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token for the current request.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTokenForRequest()
|
||||
{
|
||||
$token = $this->request->query($this->inputKey);
|
||||
|
||||
if (empty($token)) {
|
||||
$token = $this->request->input($this->inputKey);
|
||||
}
|
||||
|
||||
if (empty($token)) {
|
||||
$token = $this->request->bearerToken();
|
||||
}
|
||||
|
||||
if (empty($token)) {
|
||||
$token = $this->request->getPassword();
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a user's credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
*/
|
||||
public function validate(array $credentials = [])
|
||||
{
|
||||
if (empty($credentials[$this->inputKey])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$credentials = [$this->storageKey => $credentials[$this->inputKey]];
|
||||
|
||||
if ($this->provider->retrieveByCredentials($credentials)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current request instance.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return $this
|
||||
*/
|
||||
public function setRequest(Request $request)
|
||||
{
|
||||
$this->request = $request;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
42
vendor/laravel/framework/src/Illuminate/Auth/composer.json
vendored
Normal file
42
vendor/laravel/framework/src/Illuminate/Auth/composer.json
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "illuminate/auth",
|
||||
"description": "The Illuminate Auth package.",
|
||||
"license": "MIT",
|
||||
"homepage": "https://laravel.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"illuminate/contracts": "5.8.*",
|
||||
"illuminate/http": "5.8.*",
|
||||
"illuminate/queue": "5.8.*",
|
||||
"illuminate/support": "5.8.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Auth\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/console": "Required to use the auth:clear-resets command (5.8.*).",
|
||||
"illuminate/queue": "Required to fire login / logout events (5.8.*).",
|
||||
"illuminate/session": "Required to use the session based guard (5.8.*)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
25
vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastController.php
vendored
Normal file
25
vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastController.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
class BroadcastController extends Controller
|
||||
{
|
||||
/**
|
||||
* Authenticate the request for channel access.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function authenticate(Request $request)
|
||||
{
|
||||
if ($request->hasSession()) {
|
||||
$request->session()->reflash();
|
||||
}
|
||||
|
||||
return Broadcast::auth($request);
|
||||
}
|
||||
}
|
||||
111
vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php
vendored
Normal file
111
vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastEvent.php
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionProperty;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Contracts\Broadcasting\Broadcaster;
|
||||
|
||||
class BroadcastEvent implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* The event instance.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $event;
|
||||
|
||||
/**
|
||||
* Create a new job handler instance.
|
||||
*
|
||||
* @param mixed $event
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($event)
|
||||
{
|
||||
$this->event = $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the queued job.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Broadcasting\Broadcaster $broadcaster
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Broadcaster $broadcaster)
|
||||
{
|
||||
$name = method_exists($this->event, 'broadcastAs')
|
||||
? $this->event->broadcastAs() : get_class($this->event);
|
||||
|
||||
$broadcaster->broadcast(
|
||||
Arr::wrap($this->event->broadcastOn()), $name,
|
||||
$this->getPayloadFromEvent($this->event)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the payload for the given event.
|
||||
*
|
||||
* @param mixed $event
|
||||
* @return array
|
||||
*/
|
||||
protected function getPayloadFromEvent($event)
|
||||
{
|
||||
if (method_exists($event, 'broadcastWith')) {
|
||||
return array_merge(
|
||||
$event->broadcastWith(), ['socket' => data_get($event, 'socket')]
|
||||
);
|
||||
}
|
||||
|
||||
$payload = [];
|
||||
|
||||
foreach ((new ReflectionClass($event))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
|
||||
$payload[$property->getName()] = $this->formatProperty($property->getValue($event));
|
||||
}
|
||||
|
||||
unset($payload['broadcastQueue']);
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given value for a property.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
protected function formatProperty($value)
|
||||
{
|
||||
if ($value instanceof Arrayable) {
|
||||
return $value->toArray();
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display name for the queued job.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function displayName()
|
||||
{
|
||||
return get_class($this->event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the instance for cloning.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$this->event = clone $this->event;
|
||||
}
|
||||
}
|
||||
10
vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastException.php
vendored
Normal file
10
vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastException.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class BroadcastException extends RuntimeException
|
||||
{
|
||||
//
|
||||
}
|
||||
321
vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php
vendored
Normal file
321
vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php
vendored
Normal file
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use Closure;
|
||||
use Pusher\Pusher;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use InvalidArgumentException;
|
||||
use Illuminate\Broadcasting\Broadcasters\LogBroadcaster;
|
||||
use Illuminate\Broadcasting\Broadcasters\NullBroadcaster;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||
use Illuminate\Broadcasting\Broadcasters\RedisBroadcaster;
|
||||
use Illuminate\Broadcasting\Broadcasters\PusherBroadcaster;
|
||||
use Illuminate\Contracts\Broadcasting\Factory as FactoryContract;
|
||||
|
||||
/**
|
||||
* @mixin \Illuminate\Contracts\Broadcasting\Broadcaster
|
||||
*/
|
||||
class BroadcastManager implements FactoryContract
|
||||
{
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* The array of resolved broadcast drivers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $drivers = [];
|
||||
|
||||
/**
|
||||
* The registered custom driver creators.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customCreators = [];
|
||||
|
||||
/**
|
||||
* Create a new manager instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the routes for handling broadcast authentication and sockets.
|
||||
*
|
||||
* @param array|null $attributes
|
||||
* @return void
|
||||
*/
|
||||
public function routes(array $attributes = null)
|
||||
{
|
||||
if ($this->app->routesAreCached()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = $attributes ?: ['middleware' => ['web']];
|
||||
|
||||
$this->app['router']->group($attributes, function ($router) {
|
||||
$router->match(
|
||||
['get', 'post'], '/broadcasting/auth',
|
||||
'\\'.BroadcastController::class.'@authenticate'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the socket ID for the given request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request|null $request
|
||||
* @return string|null
|
||||
*/
|
||||
public function socket($request = null)
|
||||
{
|
||||
if (! $request && ! $this->app->bound('request')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$request = $request ?: $this->app['request'];
|
||||
|
||||
return $request->header('X-Socket-ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin broadcasting an event.
|
||||
*
|
||||
* @param mixed|null $event
|
||||
* @return \Illuminate\Broadcasting\PendingBroadcast|void
|
||||
*/
|
||||
public function event($event = null)
|
||||
{
|
||||
return new PendingBroadcast($this->app->make('events'), $event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue the given event for broadcast.
|
||||
*
|
||||
* @param mixed $event
|
||||
* @return void
|
||||
*/
|
||||
public function queue($event)
|
||||
{
|
||||
$connection = $event instanceof ShouldBroadcastNow ? 'sync' : null;
|
||||
|
||||
if (is_null($connection) && isset($event->connection)) {
|
||||
$connection = $event->connection;
|
||||
}
|
||||
|
||||
$queue = null;
|
||||
|
||||
if (method_exists($event, 'broadcastQueue')) {
|
||||
$queue = $event->broadcastQueue();
|
||||
} elseif (isset($event->broadcastQueue)) {
|
||||
$queue = $event->broadcastQueue;
|
||||
} elseif (isset($event->queue)) {
|
||||
$queue = $event->queue;
|
||||
}
|
||||
|
||||
$this->app->make('queue')->connection($connection)->pushOn(
|
||||
$queue, new BroadcastEvent(clone $event)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a driver instance.
|
||||
*
|
||||
* @param string|null $driver
|
||||
* @return mixed
|
||||
*/
|
||||
public function connection($driver = null)
|
||||
{
|
||||
return $this->driver($driver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a driver instance.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function driver($name = null)
|
||||
{
|
||||
$name = $name ?: $this->getDefaultDriver();
|
||||
|
||||
return $this->drivers[$name] = $this->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get the connection from the local cache.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Broadcasting\Broadcaster
|
||||
*/
|
||||
protected function get($name)
|
||||
{
|
||||
return $this->drivers[$name] ?? $this->resolve($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given broadcaster.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Broadcasting\Broadcaster
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function resolve($name)
|
||||
{
|
||||
$config = $this->getConfig($name);
|
||||
|
||||
if (isset($this->customCreators[$config['driver']])) {
|
||||
return $this->callCustomCreator($config);
|
||||
}
|
||||
|
||||
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';
|
||||
|
||||
if (! method_exists($this, $driverMethod)) {
|
||||
throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported.");
|
||||
}
|
||||
|
||||
return $this->{$driverMethod}($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call a custom driver creator.
|
||||
*
|
||||
* @param array $config
|
||||
* @return mixed
|
||||
*/
|
||||
protected function callCustomCreator(array $config)
|
||||
{
|
||||
return $this->customCreators[$config['driver']]($this->app, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Contracts\Broadcasting\Broadcaster
|
||||
*/
|
||||
protected function createPusherDriver(array $config)
|
||||
{
|
||||
$pusher = new Pusher(
|
||||
$config['key'], $config['secret'],
|
||||
$config['app_id'], $config['options'] ?? []
|
||||
);
|
||||
|
||||
if ($config['log'] ?? false) {
|
||||
$pusher->setLogger($this->app->make(LoggerInterface::class));
|
||||
}
|
||||
|
||||
return new PusherBroadcaster($pusher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Contracts\Broadcasting\Broadcaster
|
||||
*/
|
||||
protected function createRedisDriver(array $config)
|
||||
{
|
||||
return new RedisBroadcaster(
|
||||
$this->app->make('redis'), $config['connection'] ?? null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Contracts\Broadcasting\Broadcaster
|
||||
*/
|
||||
protected function createLogDriver(array $config)
|
||||
{
|
||||
return new LogBroadcaster(
|
||||
$this->app->make(LoggerInterface::class)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Contracts\Broadcasting\Broadcaster
|
||||
*/
|
||||
protected function createNullDriver(array $config)
|
||||
{
|
||||
return new NullBroadcaster;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the connection configuration.
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
protected function getConfig($name)
|
||||
{
|
||||
if (! is_null($name) && $name !== 'null') {
|
||||
return $this->app['config']["broadcasting.connections.{$name}"];
|
||||
}
|
||||
|
||||
return ['driver' => 'null'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default driver name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->app['config']['broadcasting.default'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default driver name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultDriver($name)
|
||||
{
|
||||
$this->app['config']['broadcasting.default'] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom driver creator Closure.
|
||||
*
|
||||
* @param string $driver
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function extend($driver, Closure $callback)
|
||||
{
|
||||
$this->customCreators[$driver] = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
return $this->driver()->$method(...$parameters);
|
||||
}
|
||||
}
|
||||
45
vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastServiceProvider.php
vendored
Normal file
45
vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastServiceProvider.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory;
|
||||
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton(BroadcastManager::class, function ($app) {
|
||||
return new BroadcastManager($app);
|
||||
});
|
||||
|
||||
$this->app->singleton(BroadcasterContract::class, function ($app) {
|
||||
return $app->make(BroadcastManager::class)->connection();
|
||||
});
|
||||
|
||||
$this->app->alias(
|
||||
BroadcastManager::class, BroadcastingFactory::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [
|
||||
BroadcastManager::class,
|
||||
BroadcastingFactory::class,
|
||||
BroadcasterContract::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
329
vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php
vendored
Normal file
329
vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php
vendored
Normal file
@@ -0,0 +1,329 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting\Broadcasters;
|
||||
|
||||
use Exception;
|
||||
use ReflectionClass;
|
||||
use ReflectionFunction;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Routing\UrlRoutable;
|
||||
use Illuminate\Contracts\Routing\BindingRegistrar;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract;
|
||||
|
||||
abstract class Broadcaster implements BroadcasterContract
|
||||
{
|
||||
/**
|
||||
* The registered channel authenticators.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $channels = [];
|
||||
|
||||
/**
|
||||
* The registered channel options.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $channelOptions = [];
|
||||
|
||||
/**
|
||||
* The binding registrar instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Routing\BindingRegistrar
|
||||
*/
|
||||
protected $bindingRegistrar;
|
||||
|
||||
/**
|
||||
* Register a channel authenticator.
|
||||
*
|
||||
* @param string $channel
|
||||
* @param callable|string $callback
|
||||
* @param array $options
|
||||
* @return $this
|
||||
*/
|
||||
public function channel($channel, $callback, $options = [])
|
||||
{
|
||||
$this->channels[$channel] = $callback;
|
||||
|
||||
$this->channelOptions[$channel] = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate the incoming request for a given channel.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $channel
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
|
||||
*/
|
||||
protected function verifyUserCanAccessChannel($request, $channel)
|
||||
{
|
||||
foreach ($this->channels as $pattern => $callback) {
|
||||
if (! $this->channelNameMatchesPattern($channel, $pattern)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$parameters = $this->extractAuthParameters($pattern, $channel, $callback);
|
||||
|
||||
$handler = $this->normalizeChannelHandlerToCallable($callback);
|
||||
|
||||
if ($result = $handler($this->retrieveUser($request, $channel), ...$parameters)) {
|
||||
return $this->validAuthenticationResponse($request, $result);
|
||||
}
|
||||
}
|
||||
|
||||
throw new AccessDeniedHttpException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the parameters from the given pattern and channel.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $channel
|
||||
* @param callable|string $callback
|
||||
* @return array
|
||||
*/
|
||||
protected function extractAuthParameters($pattern, $channel, $callback)
|
||||
{
|
||||
$callbackParameters = $this->extractParameters($callback);
|
||||
|
||||
return collect($this->extractChannelKeys($pattern, $channel))->reject(function ($value, $key) {
|
||||
return is_numeric($key);
|
||||
})->map(function ($value, $key) use ($callbackParameters) {
|
||||
return $this->resolveBinding($key, $value, $callbackParameters);
|
||||
})->values()->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the parameters out of what the user passed to handle the channel authentication.
|
||||
*
|
||||
* @param callable|string $callback
|
||||
* @return \ReflectionParameter[]
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function extractParameters($callback)
|
||||
{
|
||||
if (is_callable($callback)) {
|
||||
return (new ReflectionFunction($callback))->getParameters();
|
||||
} elseif (is_string($callback)) {
|
||||
return $this->extractParametersFromClass($callback);
|
||||
}
|
||||
|
||||
throw new Exception('Given channel handler is an unknown type.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the parameters out of a class channel's "join" method.
|
||||
*
|
||||
* @param string $callback
|
||||
* @return \ReflectionParameter[]
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function extractParametersFromClass($callback)
|
||||
{
|
||||
$reflection = new ReflectionClass($callback);
|
||||
|
||||
if (! $reflection->hasMethod('join')) {
|
||||
throw new Exception('Class based channel must define a "join" method.');
|
||||
}
|
||||
|
||||
return $reflection->getMethod('join')->getParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the channel keys from the incoming channel name.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @param string $channel
|
||||
* @return array
|
||||
*/
|
||||
protected function extractChannelKeys($pattern, $channel)
|
||||
{
|
||||
preg_match('/^'.preg_replace('/\{(.*?)\}/', '(?<$1>[^\.]+)', $pattern).'/', $channel, $keys);
|
||||
|
||||
return $keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given parameter binding.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @param array $callbackParameters
|
||||
* @return mixed
|
||||
*/
|
||||
protected function resolveBinding($key, $value, $callbackParameters)
|
||||
{
|
||||
$newValue = $this->resolveExplicitBindingIfPossible($key, $value);
|
||||
|
||||
return $newValue === $value ? $this->resolveImplicitBindingIfPossible(
|
||||
$key, $value, $callbackParameters
|
||||
) : $newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve an explicit parameter binding if applicable.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
protected function resolveExplicitBindingIfPossible($key, $value)
|
||||
{
|
||||
$binder = $this->binder();
|
||||
|
||||
if ($binder && $binder->getBindingCallback($key)) {
|
||||
return call_user_func($binder->getBindingCallback($key), $value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve an implicit parameter binding if applicable.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param array $callbackParameters
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
|
||||
*/
|
||||
protected function resolveImplicitBindingIfPossible($key, $value, $callbackParameters)
|
||||
{
|
||||
foreach ($callbackParameters as $parameter) {
|
||||
if (! $this->isImplicitlyBindable($key, $parameter)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$instance = $parameter->getClass()->newInstance();
|
||||
|
||||
if (! $model = $instance->resolveRouteBinding($value)) {
|
||||
throw new AccessDeniedHttpException;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a given key and parameter is implicitly bindable.
|
||||
*
|
||||
* @param string $key
|
||||
* @param \ReflectionParameter $parameter
|
||||
* @return bool
|
||||
*/
|
||||
protected function isImplicitlyBindable($key, $parameter)
|
||||
{
|
||||
return $parameter->name === $key && $parameter->getClass() &&
|
||||
$parameter->getClass()->isSubclassOf(UrlRoutable::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the channel array into an array of strings.
|
||||
*
|
||||
* @param array $channels
|
||||
* @return array
|
||||
*/
|
||||
protected function formatChannels(array $channels)
|
||||
{
|
||||
return array_map(function ($channel) {
|
||||
return (string) $channel;
|
||||
}, $channels);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model binding registrar instance.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Routing\BindingRegistrar
|
||||
*/
|
||||
protected function binder()
|
||||
{
|
||||
if (! $this->bindingRegistrar) {
|
||||
$this->bindingRegistrar = Container::getInstance()->bound(BindingRegistrar::class)
|
||||
? Container::getInstance()->make(BindingRegistrar::class) : null;
|
||||
}
|
||||
|
||||
return $this->bindingRegistrar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the given callback into a callable.
|
||||
*
|
||||
* @param mixed $callback
|
||||
* @return callable|\Closure
|
||||
*/
|
||||
protected function normalizeChannelHandlerToCallable($callback)
|
||||
{
|
||||
return is_callable($callback) ? $callback : function (...$args) use ($callback) {
|
||||
return Container::getInstance()
|
||||
->make($callback)
|
||||
->join(...$args);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the authenticated user using the configured guard (if any).
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $channel
|
||||
* @return mixed
|
||||
*/
|
||||
protected function retrieveUser($request, $channel)
|
||||
{
|
||||
$options = $this->retrieveChannelOptions($channel);
|
||||
|
||||
$guards = $options['guards'] ?? null;
|
||||
|
||||
if (is_null($guards)) {
|
||||
return $request->user();
|
||||
}
|
||||
|
||||
foreach (Arr::wrap($guards) as $guard) {
|
||||
if ($user = $request->user($guard)) {
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve options for a certain channel.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return array
|
||||
*/
|
||||
protected function retrieveChannelOptions($channel)
|
||||
{
|
||||
foreach ($this->channelOptions as $pattern => $options) {
|
||||
if (! $this->channelNameMatchesPattern($channel, $pattern)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if channel name from request match a pattern from registered channels.
|
||||
*
|
||||
* @param string $channel
|
||||
* @param string $pattern
|
||||
* @return bool
|
||||
*/
|
||||
protected function channelNameMatchesPattern($channel, $pattern)
|
||||
{
|
||||
return Str::is(preg_replace('/\{(.*?)\}/', '*', $pattern), $channel);
|
||||
}
|
||||
}
|
||||
54
vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/LogBroadcaster.php
vendored
Normal file
54
vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/LogBroadcaster.php
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting\Broadcasters;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class LogBroadcaster extends Broadcaster
|
||||
{
|
||||
/**
|
||||
* The logger implementation.
|
||||
*
|
||||
* @var \Psr\Log\LoggerInterface
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* Create a new broadcaster instance.
|
||||
*
|
||||
* @param \Psr\Log\LoggerInterface $logger
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(LoggerInterface $logger)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function auth($request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validAuthenticationResponse($request, $result)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function broadcast(array $channels, $event, array $payload = [])
|
||||
{
|
||||
$channels = implode(', ', $this->formatChannels($channels));
|
||||
|
||||
$payload = json_encode($payload, JSON_PRETTY_PRINT);
|
||||
|
||||
$this->logger->info('Broadcasting ['.$event.'] on channels ['.$channels.'] with payload:'.PHP_EOL.$payload);
|
||||
}
|
||||
}
|
||||
30
vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/NullBroadcaster.php
vendored
Normal file
30
vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/NullBroadcaster.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting\Broadcasters;
|
||||
|
||||
class NullBroadcaster extends Broadcaster
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function auth($request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validAuthenticationResponse($request, $result)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function broadcast(array $channels, $event, array $payload = [])
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
133
vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php
vendored
Normal file
133
vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting\Broadcasters;
|
||||
|
||||
use Pusher\Pusher;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Broadcasting\BroadcastException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
class PusherBroadcaster extends Broadcaster
|
||||
{
|
||||
use UsePusherChannelConventions;
|
||||
|
||||
/**
|
||||
* The Pusher SDK instance.
|
||||
*
|
||||
* @var \Pusher\Pusher
|
||||
*/
|
||||
protected $pusher;
|
||||
|
||||
/**
|
||||
* Create a new broadcaster instance.
|
||||
*
|
||||
* @param \Pusher\Pusher $pusher
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Pusher $pusher)
|
||||
{
|
||||
$this->pusher = $pusher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate the incoming request for a given channel.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
|
||||
*/
|
||||
public function auth($request)
|
||||
{
|
||||
$channelName = $this->normalizeChannelName($request->channel_name);
|
||||
|
||||
if ($this->isGuardedChannel($request->channel_name) &&
|
||||
! $this->retrieveUser($request, $channelName)) {
|
||||
throw new AccessDeniedHttpException;
|
||||
}
|
||||
|
||||
return parent::verifyUserCanAccessChannel(
|
||||
$request, $channelName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the valid authentication response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param mixed $result
|
||||
* @return mixed
|
||||
*/
|
||||
public function validAuthenticationResponse($request, $result)
|
||||
{
|
||||
if (Str::startsWith($request->channel_name, 'private')) {
|
||||
return $this->decodePusherResponse(
|
||||
$request, $this->pusher->socket_auth($request->channel_name, $request->socket_id)
|
||||
);
|
||||
}
|
||||
|
||||
$channelName = $this->normalizeChannelName($request->channel_name);
|
||||
|
||||
return $this->decodePusherResponse(
|
||||
$request,
|
||||
$this->pusher->presence_auth(
|
||||
$request->channel_name, $request->socket_id,
|
||||
$this->retrieveUser($request, $channelName)->getAuthIdentifier(), $result
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode the given Pusher response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param mixed $response
|
||||
* @return array
|
||||
*/
|
||||
protected function decodePusherResponse($request, $response)
|
||||
{
|
||||
if (! $request->input('callback', false)) {
|
||||
return json_decode($response, true);
|
||||
}
|
||||
|
||||
return response()->json(json_decode($response, true))
|
||||
->withCallback($request->callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast the given event.
|
||||
*
|
||||
* @param array $channels
|
||||
* @param string $event
|
||||
* @param array $payload
|
||||
* @return void
|
||||
*/
|
||||
public function broadcast(array $channels, $event, array $payload = [])
|
||||
{
|
||||
$socket = Arr::pull($payload, 'socket');
|
||||
|
||||
$response = $this->pusher->trigger(
|
||||
$this->formatChannels($channels), $event, $payload, $socket, true
|
||||
);
|
||||
|
||||
if ((is_array($response) && $response['status'] >= 200 && $response['status'] <= 299)
|
||||
|| $response === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new BroadcastException(
|
||||
is_bool($response) ? 'Failed to connect to Pusher.' : $response['body']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Pusher SDK instance.
|
||||
*
|
||||
* @return \Pusher\Pusher
|
||||
*/
|
||||
public function getPusher()
|
||||
{
|
||||
return $this->pusher;
|
||||
}
|
||||
}
|
||||
105
vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php
vendored
Normal file
105
vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting\Broadcasters;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Contracts\Redis\Factory as Redis;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
class RedisBroadcaster extends Broadcaster
|
||||
{
|
||||
use UsePusherChannelConventions;
|
||||
|
||||
/**
|
||||
* The Redis instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Redis\Factory
|
||||
*/
|
||||
protected $redis;
|
||||
|
||||
/**
|
||||
* The Redis connection to use for broadcasting.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* Create a new broadcaster instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Redis\Factory $redis
|
||||
* @param string|null $connection
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Redis $redis, $connection = null)
|
||||
{
|
||||
$this->redis = $redis;
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate the incoming request for a given channel.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
|
||||
*/
|
||||
public function auth($request)
|
||||
{
|
||||
$channelName = $this->normalizeChannelName($request->channel_name);
|
||||
|
||||
if ($this->isGuardedChannel($request->channel_name) &&
|
||||
! $this->retrieveUser($request, $channelName)) {
|
||||
throw new AccessDeniedHttpException;
|
||||
}
|
||||
|
||||
return parent::verifyUserCanAccessChannel(
|
||||
$request, $channelName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the valid authentication response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param mixed $result
|
||||
* @return mixed
|
||||
*/
|
||||
public function validAuthenticationResponse($request, $result)
|
||||
{
|
||||
if (is_bool($result)) {
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
$channelName = $this->normalizeChannelName($request->channel_name);
|
||||
|
||||
return json_encode(['channel_data' => [
|
||||
'user_id' => $this->retrieveUser($request, $channelName)->getAuthIdentifier(),
|
||||
'user_info' => $result,
|
||||
]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast the given event.
|
||||
*
|
||||
* @param array $channels
|
||||
* @param string $event
|
||||
* @param array $payload
|
||||
* @return void
|
||||
*/
|
||||
public function broadcast(array $channels, $event, array $payload = [])
|
||||
{
|
||||
$connection = $this->redis->connection($this->connection);
|
||||
|
||||
$payload = json_encode([
|
||||
'event' => $event,
|
||||
'data' => $payload,
|
||||
'socket' => Arr::pull($payload, 'socket'),
|
||||
]);
|
||||
|
||||
foreach ($this->formatChannels($channels) as $channel) {
|
||||
$connection->publish($channel, $payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting\Broadcasters;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
trait UsePusherChannelConventions
|
||||
{
|
||||
/**
|
||||
* Return true if channel is protected by authentication.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return bool
|
||||
*/
|
||||
public function isGuardedChannel($channel)
|
||||
{
|
||||
return Str::startsWith($channel, ['private-', 'presence-']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove prefix from channel name.
|
||||
*
|
||||
* @param string $channel
|
||||
* @return string
|
||||
*/
|
||||
public function normalizeChannelName($channel)
|
||||
{
|
||||
if ($this->isGuardedChannel($channel)) {
|
||||
return Str::startsWith($channel, 'private-')
|
||||
? Str::replaceFirst('private-', '', $channel)
|
||||
: Str::replaceFirst('presence-', '', $channel);
|
||||
}
|
||||
|
||||
return $channel;
|
||||
}
|
||||
}
|
||||
34
vendor/laravel/framework/src/Illuminate/Broadcasting/Channel.php
vendored
Normal file
34
vendor/laravel/framework/src/Illuminate/Broadcasting/Channel.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
class Channel
|
||||
{
|
||||
/**
|
||||
* The channel's name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Create a new channel instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the channel instance to a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
39
vendor/laravel/framework/src/Illuminate/Broadcasting/InteractsWithSockets.php
vendored
Normal file
39
vendor/laravel/framework/src/Illuminate/Broadcasting/InteractsWithSockets.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
trait InteractsWithSockets
|
||||
{
|
||||
/**
|
||||
* The socket ID for the user that raised the event.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $socket;
|
||||
|
||||
/**
|
||||
* Exclude the current user from receiving the broadcast.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function dontBroadcastToCurrentUser()
|
||||
{
|
||||
$this->socket = Broadcast::socket();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast the event to everyone.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function broadcastToEveryone()
|
||||
{
|
||||
$this->socket = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
21
vendor/laravel/framework/src/Illuminate/Broadcasting/LICENSE.md
vendored
Normal file
21
vendor/laravel/framework/src/Illuminate/Broadcasting/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Taylor Otwell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
59
vendor/laravel/framework/src/Illuminate/Broadcasting/PendingBroadcast.php
vendored
Normal file
59
vendor/laravel/framework/src/Illuminate/Broadcasting/PendingBroadcast.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class PendingBroadcast
|
||||
{
|
||||
/**
|
||||
* The event dispatcher implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
protected $events;
|
||||
|
||||
/**
|
||||
* The event instance.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $event;
|
||||
|
||||
/**
|
||||
* Create a new pending broadcast instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
* @param mixed $event
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Dispatcher $events, $event)
|
||||
{
|
||||
$this->event = $event;
|
||||
$this->events = $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast the event to everyone except the current user.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function toOthers()
|
||||
{
|
||||
if (method_exists($this->event, 'dontBroadcastToCurrentUser')) {
|
||||
$this->event->dontBroadcastToCurrentUser();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the object's destruction.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->events->dispatch($this->event);
|
||||
}
|
||||
}
|
||||
17
vendor/laravel/framework/src/Illuminate/Broadcasting/PresenceChannel.php
vendored
Normal file
17
vendor/laravel/framework/src/Illuminate/Broadcasting/PresenceChannel.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
class PresenceChannel extends Channel
|
||||
{
|
||||
/**
|
||||
* Create a new channel instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
parent::__construct('presence-'.$name);
|
||||
}
|
||||
}
|
||||
17
vendor/laravel/framework/src/Illuminate/Broadcasting/PrivateChannel.php
vendored
Normal file
17
vendor/laravel/framework/src/Illuminate/Broadcasting/PrivateChannel.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Broadcasting;
|
||||
|
||||
class PrivateChannel extends Channel
|
||||
{
|
||||
/**
|
||||
* Create a new channel instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
parent::__construct('private-'.$name);
|
||||
}
|
||||
}
|
||||
42
vendor/laravel/framework/src/Illuminate/Broadcasting/composer.json
vendored
Normal file
42
vendor/laravel/framework/src/Illuminate/Broadcasting/composer.json
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "illuminate/broadcasting",
|
||||
"description": "The Illuminate Broadcasting package.",
|
||||
"license": "MIT",
|
||||
"homepage": "https://laravel.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-json": "*",
|
||||
"psr/log": "^1.0",
|
||||
"illuminate/bus": "5.8.*",
|
||||
"illuminate/contracts": "5.8.*",
|
||||
"illuminate/queue": "5.8.*",
|
||||
"illuminate/support": "5.8.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Broadcasting\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^3.0)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
48
vendor/laravel/framework/src/Illuminate/Bus/BusServiceProvider.php
vendored
Normal file
48
vendor/laravel/framework/src/Illuminate/Bus/BusServiceProvider.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Bus;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
use Illuminate\Contracts\Bus\Dispatcher as DispatcherContract;
|
||||
use Illuminate\Contracts\Queue\Factory as QueueFactoryContract;
|
||||
use Illuminate\Contracts\Bus\QueueingDispatcher as QueueingDispatcherContract;
|
||||
|
||||
class BusServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton(Dispatcher::class, function ($app) {
|
||||
return new Dispatcher($app, function ($connection = null) use ($app) {
|
||||
return $app[QueueFactoryContract::class]->connection($connection);
|
||||
});
|
||||
});
|
||||
|
||||
$this->app->alias(
|
||||
Dispatcher::class, DispatcherContract::class
|
||||
);
|
||||
|
||||
$this->app->alias(
|
||||
Dispatcher::class, QueueingDispatcherContract::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [
|
||||
Dispatcher::class,
|
||||
DispatcherContract::class,
|
||||
QueueingDispatcherContract::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
212
vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php
vendored
Normal file
212
vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Bus;
|
||||
|
||||
use Closure;
|
||||
use RuntimeException;
|
||||
use Illuminate\Pipeline\Pipeline;
|
||||
use Illuminate\Contracts\Queue\Queue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Bus\QueueingDispatcher;
|
||||
|
||||
class Dispatcher implements QueueingDispatcher
|
||||
{
|
||||
/**
|
||||
* The container implementation.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Container\Container
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* The pipeline instance for the bus.
|
||||
*
|
||||
* @var \Illuminate\Pipeline\Pipeline
|
||||
*/
|
||||
protected $pipeline;
|
||||
|
||||
/**
|
||||
* The pipes to send commands through before dispatching.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $pipes = [];
|
||||
|
||||
/**
|
||||
* The command to handler mapping for non-self-handling events.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $handlers = [];
|
||||
|
||||
/**
|
||||
* The queue resolver callback.
|
||||
*
|
||||
* @var \Closure|null
|
||||
*/
|
||||
protected $queueResolver;
|
||||
|
||||
/**
|
||||
* Create a new command dispatcher instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Container\Container $container
|
||||
* @param \Closure|null $queueResolver
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Container $container, Closure $queueResolver = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->queueResolver = $queueResolver;
|
||||
$this->pipeline = new Pipeline($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a command to its appropriate handler.
|
||||
*
|
||||
* @param mixed $command
|
||||
* @return mixed
|
||||
*/
|
||||
public function dispatch($command)
|
||||
{
|
||||
if ($this->queueResolver && $this->commandShouldBeQueued($command)) {
|
||||
return $this->dispatchToQueue($command);
|
||||
}
|
||||
|
||||
return $this->dispatchNow($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a command to its appropriate handler in the current process.
|
||||
*
|
||||
* @param mixed $command
|
||||
* @param mixed $handler
|
||||
* @return mixed
|
||||
*/
|
||||
public function dispatchNow($command, $handler = null)
|
||||
{
|
||||
if ($handler || $handler = $this->getCommandHandler($command)) {
|
||||
$callback = function ($command) use ($handler) {
|
||||
return $handler->handle($command);
|
||||
};
|
||||
} else {
|
||||
$callback = function ($command) {
|
||||
return $this->container->call([$command, 'handle']);
|
||||
};
|
||||
}
|
||||
|
||||
return $this->pipeline->send($command)->through($this->pipes)->then($callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given command has a handler.
|
||||
*
|
||||
* @param mixed $command
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCommandHandler($command)
|
||||
{
|
||||
return array_key_exists(get_class($command), $this->handlers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the handler for a command.
|
||||
*
|
||||
* @param mixed $command
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function getCommandHandler($command)
|
||||
{
|
||||
if ($this->hasCommandHandler($command)) {
|
||||
return $this->container->make($this->handlers[get_class($command)]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given command should be queued.
|
||||
*
|
||||
* @param mixed $command
|
||||
* @return bool
|
||||
*/
|
||||
protected function commandShouldBeQueued($command)
|
||||
{
|
||||
return $command instanceof ShouldQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a command to its appropriate handler behind a queue.
|
||||
*
|
||||
* @param mixed $command
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function dispatchToQueue($command)
|
||||
{
|
||||
$connection = $command->connection ?? null;
|
||||
|
||||
$queue = call_user_func($this->queueResolver, $connection);
|
||||
|
||||
if (! $queue instanceof Queue) {
|
||||
throw new RuntimeException('Queue resolver did not return a Queue implementation.');
|
||||
}
|
||||
|
||||
if (method_exists($command, 'queue')) {
|
||||
return $command->queue($queue, $command);
|
||||
}
|
||||
|
||||
return $this->pushCommandToQueue($queue, $command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push the command onto the given queue instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Queue\Queue $queue
|
||||
* @param mixed $command
|
||||
* @return mixed
|
||||
*/
|
||||
protected function pushCommandToQueue($queue, $command)
|
||||
{
|
||||
if (isset($command->queue, $command->delay)) {
|
||||
return $queue->laterOn($command->queue, $command->delay, $command);
|
||||
}
|
||||
|
||||
if (isset($command->queue)) {
|
||||
return $queue->pushOn($command->queue, $command);
|
||||
}
|
||||
|
||||
if (isset($command->delay)) {
|
||||
return $queue->later($command->delay, $command);
|
||||
}
|
||||
|
||||
return $queue->push($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pipes through which commands should be piped before dispatching.
|
||||
*
|
||||
* @param array $pipes
|
||||
* @return $this
|
||||
*/
|
||||
public function pipeThrough(array $pipes)
|
||||
{
|
||||
$this->pipes = $pipes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a command to a handler.
|
||||
*
|
||||
* @param array $map
|
||||
* @return $this
|
||||
*/
|
||||
public function map(array $map)
|
||||
{
|
||||
$this->handlers = array_merge($this->handlers, $map);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
21
vendor/laravel/framework/src/Illuminate/Bus/LICENSE.md
vendored
Normal file
21
vendor/laravel/framework/src/Illuminate/Bus/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Taylor Otwell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
150
vendor/laravel/framework/src/Illuminate/Bus/Queueable.php
vendored
Normal file
150
vendor/laravel/framework/src/Illuminate/Bus/Queueable.php
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Bus;
|
||||
|
||||
trait Queueable
|
||||
{
|
||||
/**
|
||||
* The name of the connection the job should be sent to.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* The name of the queue the job should be sent to.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $queue;
|
||||
|
||||
/**
|
||||
* The name of the connection the chain should be sent to.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $chainConnection;
|
||||
|
||||
/**
|
||||
* The name of the queue the chain should be sent to.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $chainQueue;
|
||||
|
||||
/**
|
||||
* The number of seconds before the job should be made available.
|
||||
*
|
||||
* @var \DateTimeInterface|\DateInterval|int|null
|
||||
*/
|
||||
public $delay;
|
||||
|
||||
/**
|
||||
* The jobs that should run if this job is successful.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $chained = [];
|
||||
|
||||
/**
|
||||
* Set the desired connection for the job.
|
||||
*
|
||||
* @param string|null $connection
|
||||
* @return $this
|
||||
*/
|
||||
public function onConnection($connection)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the desired queue for the job.
|
||||
*
|
||||
* @param string|null $queue
|
||||
* @return $this
|
||||
*/
|
||||
public function onQueue($queue)
|
||||
{
|
||||
$this->queue = $queue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the desired connection for the chain.
|
||||
*
|
||||
* @param string|null $connection
|
||||
* @return $this
|
||||
*/
|
||||
public function allOnConnection($connection)
|
||||
{
|
||||
$this->chainConnection = $connection;
|
||||
$this->connection = $connection;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the desired queue for the chain.
|
||||
*
|
||||
* @param string|null $queue
|
||||
* @return $this
|
||||
*/
|
||||
public function allOnQueue($queue)
|
||||
{
|
||||
$this->chainQueue = $queue;
|
||||
$this->queue = $queue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the desired delay for the job.
|
||||
*
|
||||
* @param \DateTimeInterface|\DateInterval|int|null $delay
|
||||
* @return $this
|
||||
*/
|
||||
public function delay($delay)
|
||||
{
|
||||
$this->delay = $delay;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the jobs that should run if this job is successful.
|
||||
*
|
||||
* @param array $chain
|
||||
* @return $this
|
||||
*/
|
||||
public function chain($chain)
|
||||
{
|
||||
$this->chained = collect($chain)->map(function ($job) {
|
||||
return serialize($job);
|
||||
})->all();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the next job on the chain.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dispatchNextJobInChain()
|
||||
{
|
||||
if (! empty($this->chained)) {
|
||||
dispatch(tap(unserialize(array_shift($this->chained)), function ($next) {
|
||||
$next->chained = $this->chained;
|
||||
|
||||
$next->onConnection($next->connection ?: $this->chainConnection);
|
||||
$next->onQueue($next->queue ?: $this->chainQueue);
|
||||
|
||||
$next->chainConnection = $this->chainConnection;
|
||||
$next->chainQueue = $this->chainQueue;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
36
vendor/laravel/framework/src/Illuminate/Bus/composer.json
vendored
Normal file
36
vendor/laravel/framework/src/Illuminate/Bus/composer.json
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "illuminate/bus",
|
||||
"description": "The Illuminate Bus package.",
|
||||
"license": "MIT",
|
||||
"homepage": "https://laravel.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"illuminate/contracts": "5.8.*",
|
||||
"illuminate/pipeline": "5.8.*",
|
||||
"illuminate/support": "5.8.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Bus\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.8-dev"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
130
vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php
vendored
Normal file
130
vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
class ApcStore extends TaggableStore
|
||||
{
|
||||
use RetrievesMultipleKeys;
|
||||
|
||||
/**
|
||||
* The APC wrapper instance.
|
||||
*
|
||||
* @var \Illuminate\Cache\ApcWrapper
|
||||
*/
|
||||
protected $apc;
|
||||
|
||||
/**
|
||||
* A string that should be prepended to keys.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix;
|
||||
|
||||
/**
|
||||
* Create a new APC store.
|
||||
*
|
||||
* @param \Illuminate\Cache\ApcWrapper $apc
|
||||
* @param string $prefix
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ApcWrapper $apc, $prefix = '')
|
||||
{
|
||||
$this->apc = $apc;
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an item from the cache by key.
|
||||
*
|
||||
* @param string|array $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
$value = $this->apc->get($this->prefix.$key);
|
||||
|
||||
if ($value !== false) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
return $this->apc->put($this->prefix.$key, $value, $seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
*/
|
||||
public function increment($key, $value = 1)
|
||||
{
|
||||
return $this->apc->increment($this->prefix.$key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
*/
|
||||
public function decrement($key, $value = 1)
|
||||
{
|
||||
return $this->apc->decrement($this->prefix.$key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache indefinitely.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
return $this->put($key, $value, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function forget($key)
|
||||
{
|
||||
return $this->apc->delete($this->prefix.$key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all items from the cache.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
return $this->apc->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cache key prefix.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
}
|
||||
92
vendor/laravel/framework/src/Illuminate/Cache/ApcWrapper.php
vendored
Normal file
92
vendor/laravel/framework/src/Illuminate/Cache/ApcWrapper.php
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
class ApcWrapper
|
||||
{
|
||||
/**
|
||||
* Indicates if APCu is supported.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $apcu = false;
|
||||
|
||||
/**
|
||||
* Create a new APC wrapper instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->apcu = function_exists('apcu_fetch');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item from the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
return $this->apcu ? apcu_fetch($key) : apc_fetch($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $seconds
|
||||
* @return array|bool
|
||||
*/
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
return $this->apcu ? apcu_store($key, $value, $seconds) : apc_store($key, $value, $seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
*/
|
||||
public function increment($key, $value)
|
||||
{
|
||||
return $this->apcu ? apcu_inc($key, $value) : apc_inc($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
*/
|
||||
public function decrement($key, $value)
|
||||
{
|
||||
return $this->apcu ? apcu_dec($key, $value) : apc_dec($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
return $this->apcu ? apcu_delete($key) : apc_delete($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all items from the cache.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
return $this->apcu ? apcu_clear_cache() : apc_clear_cache('user');
|
||||
}
|
||||
}
|
||||
161
vendor/laravel/framework/src/Illuminate/Cache/ArrayStore.php
vendored
Normal file
161
vendor/laravel/framework/src/Illuminate/Cache/ArrayStore.php
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Illuminate\Support\InteractsWithTime;
|
||||
|
||||
class ArrayStore extends TaggableStore
|
||||
{
|
||||
use InteractsWithTime, RetrievesMultipleKeys;
|
||||
|
||||
/**
|
||||
* The array of stored values.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $storage = [];
|
||||
|
||||
/**
|
||||
* Retrieve an item from the cache by key.
|
||||
*
|
||||
* @param string|array $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
if (! isset($this->storage[$key])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$item = $this->storage[$key];
|
||||
|
||||
$expiresAt = $item['expiresAt'] ?? 0;
|
||||
|
||||
if ($expiresAt !== 0 && $this->currentTime() > $expiresAt) {
|
||||
$this->forget($key);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return $item['value'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
$this->storage[$key] = [
|
||||
'value' => $value,
|
||||
'expiresAt' => $this->calculateExpiration($seconds),
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int
|
||||
*/
|
||||
public function increment($key, $value = 1)
|
||||
{
|
||||
if (! isset($this->storage[$key])) {
|
||||
$this->forever($key, $value);
|
||||
|
||||
return $this->storage[$key]['value'];
|
||||
}
|
||||
|
||||
$this->storage[$key]['value'] = ((int) $this->storage[$key]['value']) + $value;
|
||||
|
||||
return $this->storage[$key]['value'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int
|
||||
*/
|
||||
public function decrement($key, $value = 1)
|
||||
{
|
||||
return $this->increment($key, $value * -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache indefinitely.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
return $this->put($key, $value, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function forget($key)
|
||||
{
|
||||
unset($this->storage[$key]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all items from the cache.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
$this->storage = [];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cache key prefix.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expiration time of the key.
|
||||
*
|
||||
* @param int $seconds
|
||||
* @return int
|
||||
*/
|
||||
protected function calculateExpiration($seconds)
|
||||
{
|
||||
return $this->toTimestamp($seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UNIX timestamp for the given number of seconds.
|
||||
*
|
||||
* @param int $seconds
|
||||
* @return int
|
||||
*/
|
||||
protected function toTimestamp($seconds)
|
||||
{
|
||||
return $seconds > 0 ? $this->availableAt($seconds) : 0;
|
||||
}
|
||||
}
|
||||
359
vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php
vendored
Normal file
359
vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Arr;
|
||||
use InvalidArgumentException;
|
||||
use Aws\DynamoDb\DynamoDbClient;
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
use Illuminate\Contracts\Cache\Factory as FactoryContract;
|
||||
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
|
||||
|
||||
/**
|
||||
* @mixin \Illuminate\Contracts\Cache\Repository
|
||||
*/
|
||||
class CacheManager implements FactoryContract
|
||||
{
|
||||
/**
|
||||
* The application instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* The array of resolved cache stores.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $stores = [];
|
||||
|
||||
/**
|
||||
* The registered custom driver creators.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customCreators = [];
|
||||
|
||||
/**
|
||||
* Create a new Cache manager instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a cache store instance by name, wrapped in a repository.
|
||||
*
|
||||
* @param string|null $name
|
||||
* @return \Illuminate\Contracts\Cache\Repository
|
||||
*/
|
||||
public function store($name = null)
|
||||
{
|
||||
$name = $name ?: $this->getDefaultDriver();
|
||||
|
||||
return $this->stores[$name] = $this->get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a cache driver instance.
|
||||
*
|
||||
* @param string|null $driver
|
||||
* @return \Illuminate\Contracts\Cache\Repository
|
||||
*/
|
||||
public function driver($driver = null)
|
||||
{
|
||||
return $this->store($driver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to get the store from the local cache.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Cache\Repository
|
||||
*/
|
||||
protected function get($name)
|
||||
{
|
||||
return $this->stores[$name] ?? $this->resolve($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given store.
|
||||
*
|
||||
* @param string $name
|
||||
* @return \Illuminate\Contracts\Cache\Repository
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function resolve($name)
|
||||
{
|
||||
$config = $this->getConfig($name);
|
||||
|
||||
if (is_null($config)) {
|
||||
throw new InvalidArgumentException("Cache store [{$name}] is not defined.");
|
||||
}
|
||||
|
||||
if (isset($this->customCreators[$config['driver']])) {
|
||||
return $this->callCustomCreator($config);
|
||||
} else {
|
||||
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';
|
||||
|
||||
if (method_exists($this, $driverMethod)) {
|
||||
return $this->{$driverMethod}($config);
|
||||
} else {
|
||||
throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call a custom driver creator.
|
||||
*
|
||||
* @param array $config
|
||||
* @return mixed
|
||||
*/
|
||||
protected function callCustomCreator(array $config)
|
||||
{
|
||||
return $this->customCreators[$config['driver']]($this->app, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the APC cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createApcDriver(array $config)
|
||||
{
|
||||
$prefix = $this->getPrefix($config);
|
||||
|
||||
return $this->repository(new ApcStore(new ApcWrapper, $prefix));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the array cache driver.
|
||||
*
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createArrayDriver()
|
||||
{
|
||||
return $this->repository(new ArrayStore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the file cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createFileDriver(array $config)
|
||||
{
|
||||
return $this->repository(new FileStore($this->app['files'], $config['path']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the Memcached cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createMemcachedDriver(array $config)
|
||||
{
|
||||
$prefix = $this->getPrefix($config);
|
||||
|
||||
$memcached = $this->app['memcached.connector']->connect(
|
||||
$config['servers'],
|
||||
$config['persistent_id'] ?? null,
|
||||
$config['options'] ?? [],
|
||||
array_filter($config['sasl'] ?? [])
|
||||
);
|
||||
|
||||
return $this->repository(new MemcachedStore($memcached, $prefix));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the Null cache driver.
|
||||
*
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createNullDriver()
|
||||
{
|
||||
return $this->repository(new NullStore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the Redis cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createRedisDriver(array $config)
|
||||
{
|
||||
$redis = $this->app['redis'];
|
||||
|
||||
$connection = $config['connection'] ?? 'default';
|
||||
|
||||
return $this->repository(new RedisStore($redis, $this->getPrefix($config), $connection));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the database cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createDatabaseDriver(array $config)
|
||||
{
|
||||
$connection = $this->app['db']->connection($config['connection'] ?? null);
|
||||
|
||||
return $this->repository(
|
||||
new DatabaseStore(
|
||||
$connection, $config['table'], $this->getPrefix($config)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the DynamoDB cache driver.
|
||||
*
|
||||
* @param array $config
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function createDynamodbDriver(array $config)
|
||||
{
|
||||
$dynamoConfig = [
|
||||
'region' => $config['region'],
|
||||
'version' => 'latest',
|
||||
'endpoint' => $config['endpoint'] ?? null,
|
||||
];
|
||||
|
||||
if ($config['key'] && $config['secret']) {
|
||||
$dynamoConfig['credentials'] = Arr::only(
|
||||
$config, ['key', 'secret', 'token']
|
||||
);
|
||||
}
|
||||
|
||||
return $this->repository(
|
||||
new DynamoDbStore(
|
||||
new DynamoDbClient($dynamoConfig),
|
||||
$config['table'],
|
||||
$config['attributes']['key'] ?? 'key',
|
||||
$config['attributes']['value'] ?? 'value',
|
||||
$config['attributes']['expiration'] ?? 'expires_at',
|
||||
$this->getPrefix($config)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new cache repository with the given implementation.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Cache\Store $store
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
public function repository(Store $store)
|
||||
{
|
||||
$repository = new Repository($store);
|
||||
|
||||
if ($this->app->bound(DispatcherContract::class)) {
|
||||
$repository->setEventDispatcher(
|
||||
$this->app[DispatcherContract::class]
|
||||
);
|
||||
}
|
||||
|
||||
return $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cache prefix.
|
||||
*
|
||||
* @param array $config
|
||||
* @return string
|
||||
*/
|
||||
protected function getPrefix(array $config)
|
||||
{
|
||||
return $config['prefix'] ?? $this->app['config']['cache.prefix'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cache connection configuration.
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
protected function getConfig($name)
|
||||
{
|
||||
return $this->app['config']["cache.stores.{$name}"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default cache driver name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultDriver()
|
||||
{
|
||||
return $this->app['config']['cache.default'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default cache driver name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultDriver($name)
|
||||
{
|
||||
$this->app['config']['cache.default'] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the given driver instances.
|
||||
*
|
||||
* @param array|string|null $name
|
||||
* @return $this
|
||||
*/
|
||||
public function forgetDriver($name = null)
|
||||
{
|
||||
$name = $name ?? $this->getDefaultDriver();
|
||||
|
||||
foreach ((array) $name as $cacheName) {
|
||||
if (isset($this->stores[$cacheName])) {
|
||||
unset($this->stores[$cacheName]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom driver creator Closure.
|
||||
*
|
||||
* @param string $driver
|
||||
* @param \Closure $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function extend($driver, Closure $callback)
|
||||
{
|
||||
$this->customCreators[$driver] = $callback->bindTo($this, $this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically call the default driver instance.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
return $this->store()->$method(...$parameters);
|
||||
}
|
||||
}
|
||||
41
vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php
vendored
Normal file
41
vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Contracts\Support\DeferrableProvider;
|
||||
|
||||
class CacheServiceProvider extends ServiceProvider implements DeferrableProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('cache', function ($app) {
|
||||
return new CacheManager($app);
|
||||
});
|
||||
|
||||
$this->app->singleton('cache.store', function ($app) {
|
||||
return $app['cache']->driver();
|
||||
});
|
||||
|
||||
$this->app->singleton('memcached.connector', function () {
|
||||
return new MemcachedConnector;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [
|
||||
'cache', 'cache.store', 'memcached.connector',
|
||||
];
|
||||
}
|
||||
}
|
||||
81
vendor/laravel/framework/src/Illuminate/Cache/Console/CacheTableCommand.php
vendored
Normal file
81
vendor/laravel/framework/src/Illuminate/Cache/Console/CacheTableCommand.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Composer;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
class CacheTableCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'cache:table';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Create a migration for the cache database table';
|
||||
|
||||
/**
|
||||
* The filesystem instance.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
protected $files;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Support\Composer
|
||||
*/
|
||||
protected $composer;
|
||||
|
||||
/**
|
||||
* Create a new cache table command instance.
|
||||
*
|
||||
* @param \Illuminate\Filesystem\Filesystem $files
|
||||
* @param \Illuminate\Support\Composer $composer
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Filesystem $files, Composer $composer)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->files = $files;
|
||||
$this->composer = $composer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$fullPath = $this->createBaseMigration();
|
||||
|
||||
$this->files->put($fullPath, $this->files->get(__DIR__.'/stubs/cache.stub'));
|
||||
|
||||
$this->info('Migration created successfully!');
|
||||
|
||||
$this->composer->dumpAutoloads();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a base migration file for the table.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function createBaseMigration()
|
||||
{
|
||||
$name = 'create_cache_table';
|
||||
|
||||
$path = $this->laravel->databasePath().'/migrations';
|
||||
|
||||
return $this->laravel['migration.creator']->create($name, $path);
|
||||
}
|
||||
}
|
||||
145
vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php
vendored
Normal file
145
vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Cache\CacheManager;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class ClearCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'cache:clear';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Flush the application cache';
|
||||
|
||||
/**
|
||||
* The cache manager instance.
|
||||
*
|
||||
* @var \Illuminate\Cache\CacheManager
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* The filesystem instance.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
protected $files;
|
||||
|
||||
/**
|
||||
* Create a new cache clear command instance.
|
||||
*
|
||||
* @param \Illuminate\Cache\CacheManager $cache
|
||||
* @param \Illuminate\Filesystem\Filesystem $files
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CacheManager $cache, Filesystem $files)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->cache = $cache;
|
||||
$this->files = $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->laravel['events']->dispatch(
|
||||
'cache:clearing', [$this->argument('store'), $this->tags()]
|
||||
);
|
||||
|
||||
$successful = $this->cache()->flush();
|
||||
|
||||
$this->flushFacades();
|
||||
|
||||
if (! $successful) {
|
||||
return $this->error('Failed to clear cache. Make sure you have the appropriate permissions.');
|
||||
}
|
||||
|
||||
$this->laravel['events']->dispatch(
|
||||
'cache:cleared', [$this->argument('store'), $this->tags()]
|
||||
);
|
||||
|
||||
$this->info('Application cache cleared!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the real-time facades stored in the cache directory.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function flushFacades()
|
||||
{
|
||||
if (! $this->files->exists($storagePath = storage_path('framework/cache'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->files->files($storagePath) as $file) {
|
||||
if (preg_match('/facade-.*\.php$/', $file)) {
|
||||
$this->files->delete($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cache instance for the command.
|
||||
*
|
||||
* @return \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected function cache()
|
||||
{
|
||||
$cache = $this->cache->store($this->argument('store'));
|
||||
|
||||
return empty($this->tags()) ? $cache : $cache->tags($this->tags());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tags passed to the command.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function tags()
|
||||
{
|
||||
return array_filter(explode(',', $this->option('tags')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['store', InputArgument::OPTIONAL, 'The name of the store you would like to clear'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
['tags', null, InputOption::VALUE_OPTIONAL, 'The cache tags you would like to clear', null],
|
||||
];
|
||||
}
|
||||
}
|
||||
57
vendor/laravel/framework/src/Illuminate/Cache/Console/ForgetCommand.php
vendored
Normal file
57
vendor/laravel/framework/src/Illuminate/Cache/Console/ForgetCommand.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Cache\CacheManager;
|
||||
|
||||
class ForgetCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'cache:forget {key : The key to remove} {store? : The store to remove the key from}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Remove an item from the cache';
|
||||
|
||||
/**
|
||||
* The cache manager instance.
|
||||
*
|
||||
* @var \Illuminate\Cache\CacheManager
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* Create a new cache clear command instance.
|
||||
*
|
||||
* @param \Illuminate\Cache\CacheManager $cache
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CacheManager $cache)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->cache->store($this->argument('store'))->forget(
|
||||
$this->argument('key')
|
||||
);
|
||||
|
||||
$this->info('The ['.$this->argument('key').'] key has been removed from the cache.');
|
||||
}
|
||||
}
|
||||
32
vendor/laravel/framework/src/Illuminate/Cache/Console/stubs/cache.stub
vendored
Normal file
32
vendor/laravel/framework/src/Illuminate/Cache/Console/stubs/cache.stub
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCacheTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->unique();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
}
|
||||
}
|
||||
294
vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php
vendored
Normal file
294
vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php
vendored
Normal file
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
use Illuminate\Support\InteractsWithTime;
|
||||
use Illuminate\Database\PostgresConnection;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
|
||||
class DatabaseStore implements Store
|
||||
{
|
||||
use InteractsWithTime, RetrievesMultipleKeys;
|
||||
|
||||
/**
|
||||
* The database connection instance.
|
||||
*
|
||||
* @var \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
protected $connection;
|
||||
|
||||
/**
|
||||
* The name of the cache table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table;
|
||||
|
||||
/**
|
||||
* A string that should be prepended to keys.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix;
|
||||
|
||||
/**
|
||||
* Create a new database store.
|
||||
*
|
||||
* @param \Illuminate\Database\ConnectionInterface $connection
|
||||
* @param string $table
|
||||
* @param string $prefix
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ConnectionInterface $connection, $table, $prefix = '')
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->prefix = $prefix;
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an item from the cache by key.
|
||||
*
|
||||
* @param string|array $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
$prefixed = $this->prefix.$key;
|
||||
|
||||
$cache = $this->table()->where('key', '=', $prefixed)->first();
|
||||
|
||||
// If we have a cache record we will check the expiration time against current
|
||||
// time on the system and see if the record has expired. If it has, we will
|
||||
// remove the records from the database table so it isn't returned again.
|
||||
if (is_null($cache)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cache = is_array($cache) ? (object) $cache : $cache;
|
||||
|
||||
// If this cache expiration date is past the current time, we will remove this
|
||||
// item from the cache. Then we will return a null value since the cache is
|
||||
// expired. We will use "Carbon" to make this comparison with the column.
|
||||
if ($this->currentTime() >= $cache->expiration) {
|
||||
$this->forget($key);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return $this->unserialize($cache->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
$key = $this->prefix.$key;
|
||||
|
||||
$value = $this->serialize($value);
|
||||
|
||||
$expiration = $this->getTime() + $seconds;
|
||||
|
||||
try {
|
||||
return $this->table()->insert(compact('key', 'value', 'expiration'));
|
||||
} catch (Exception $e) {
|
||||
$result = $this->table()->where('key', $key)->update(compact('value', 'expiration'));
|
||||
|
||||
return $result > 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
*/
|
||||
public function increment($key, $value = 1)
|
||||
{
|
||||
return $this->incrementOrDecrement($key, $value, function ($current, $value) {
|
||||
return $current + $value;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
*/
|
||||
public function decrement($key, $value = 1)
|
||||
{
|
||||
return $this->incrementOrDecrement($key, $value, function ($current, $value) {
|
||||
return $current - $value;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment or decrement an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param \Closure $callback
|
||||
* @return int|bool
|
||||
*/
|
||||
protected function incrementOrDecrement($key, $value, Closure $callback)
|
||||
{
|
||||
return $this->connection->transaction(function () use ($key, $value, $callback) {
|
||||
$prefixed = $this->prefix.$key;
|
||||
|
||||
$cache = $this->table()->where('key', $prefixed)
|
||||
->lockForUpdate()->first();
|
||||
|
||||
// If there is no value in the cache, we will return false here. Otherwise the
|
||||
// value will be decrypted and we will proceed with this function to either
|
||||
// increment or decrement this value based on the given action callbacks.
|
||||
if (is_null($cache)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$cache = is_array($cache) ? (object) $cache : $cache;
|
||||
|
||||
$current = $this->unserialize($cache->value);
|
||||
|
||||
// Here we'll call this callback function that was given to the function which
|
||||
// is used to either increment or decrement the function. We use a callback
|
||||
// so we do not have to recreate all this logic in each of the functions.
|
||||
$new = $callback((int) $current, $value);
|
||||
|
||||
if (! is_numeric($current)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Here we will update the values in the table. We will also encrypt the value
|
||||
// since database cache values are encrypted by default with secure storage
|
||||
// that can't be easily read. We will return the new value after storing.
|
||||
$this->table()->where('key', $prefixed)->update([
|
||||
'value' => $this->serialize($new),
|
||||
]);
|
||||
|
||||
return $new;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current system time.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getTime()
|
||||
{
|
||||
return $this->currentTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache indefinitely.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
return $this->put($key, $value, 315360000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function forget($key)
|
||||
{
|
||||
$this->table()->where('key', '=', $this->prefix.$key)->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all items from the cache.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
$this->table()->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a query builder for the cache table.
|
||||
*
|
||||
* @return \Illuminate\Database\Query\Builder
|
||||
*/
|
||||
protected function table()
|
||||
{
|
||||
return $this->connection->table($this->table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying database connection.
|
||||
*
|
||||
* @return \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
public function getConnection()
|
||||
{
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cache key prefix.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the given value.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
protected function serialize($value)
|
||||
{
|
||||
$result = serialize($value);
|
||||
|
||||
if ($this->connection instanceof PostgresConnection && Str::contains($result, "\0")) {
|
||||
$result = base64_encode($result);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unserialize the given value.
|
||||
*
|
||||
* @param string $value
|
||||
* @return mixed
|
||||
*/
|
||||
protected function unserialize($value)
|
||||
{
|
||||
if ($this->connection instanceof PostgresConnection && ! Str::contains($value, [':', ';'])) {
|
||||
$value = base64_decode($value);
|
||||
}
|
||||
|
||||
return unserialize($value);
|
||||
}
|
||||
}
|
||||
73
vendor/laravel/framework/src/Illuminate/Cache/DynamoDbLock.php
vendored
Normal file
73
vendor/laravel/framework/src/Illuminate/Cache/DynamoDbLock.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
class DynamoDbLock extends Lock
|
||||
{
|
||||
/**
|
||||
* The DynamoDB client instance.
|
||||
*
|
||||
* @var \Illuminate\Cache\DynamoDbStore
|
||||
*/
|
||||
protected $dynamo;
|
||||
|
||||
/**
|
||||
* Create a new lock instance.
|
||||
*
|
||||
* @param \Illuminate\Cache\DynamoDbStore $dynamo
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string|null $owner
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DynamoDbStore $dynamo, $name, $seconds, $owner = null)
|
||||
{
|
||||
parent::__construct($name, $seconds, $owner);
|
||||
|
||||
$this->dynamo = $dynamo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to acquire the lock.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function acquire()
|
||||
{
|
||||
return $this->dynamo->add(
|
||||
$this->name, $this->owner, $this->seconds
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the lock.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function release()
|
||||
{
|
||||
if ($this->isOwnedByCurrentProcess()) {
|
||||
$this->dynamo->forget($this->name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Release this lock in disregard of ownership.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forceRelease()
|
||||
{
|
||||
$this->dynamo->forget($this->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner value written into the driver for this lock.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getCurrentOwner()
|
||||
{
|
||||
return $this->dynamo->get($this->name);
|
||||
}
|
||||
}
|
||||
525
vendor/laravel/framework/src/Illuminate/Cache/DynamoDbStore.php
vendored
Normal file
525
vendor/laravel/framework/src/Illuminate/Cache/DynamoDbStore.php
vendored
Normal file
@@ -0,0 +1,525 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use RuntimeException;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Aws\DynamoDb\DynamoDbClient;
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
use Illuminate\Support\InteractsWithTime;
|
||||
use Illuminate\Contracts\Cache\LockProvider;
|
||||
use Aws\DynamoDb\Exception\DynamoDbException;
|
||||
|
||||
class DynamoDbStore implements Store, LockProvider
|
||||
{
|
||||
use InteractsWithTime;
|
||||
|
||||
/**
|
||||
* The DynamoDB client instance.
|
||||
*
|
||||
* @var \Aws\DynamoDb\DynamoDbClient
|
||||
*/
|
||||
protected $dynamo;
|
||||
|
||||
/**
|
||||
* The table name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table;
|
||||
|
||||
/**
|
||||
* The name of the attribute that should hold the key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $keyAttribute;
|
||||
|
||||
/**
|
||||
* The name of the attribute that should hold the value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $valueAttribute;
|
||||
|
||||
/**
|
||||
* The name of the attribute that should hold the expiration timestamp.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $expirationAttribute;
|
||||
|
||||
/**
|
||||
* A string that should be prepended to keys.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix;
|
||||
|
||||
/**
|
||||
* Create a new store instance.
|
||||
*
|
||||
* @param \Aws\DynamoDb\DynamoDbClient $dynamo
|
||||
* @param string $table
|
||||
* @param string $keyAttribute
|
||||
* @param string $valueAttribute
|
||||
* @param string $expirationAttribute
|
||||
* @param string $prefix
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DynamoDbClient $dynamo,
|
||||
$table,
|
||||
$keyAttribute = 'key',
|
||||
$valueAttribute = 'value',
|
||||
$expirationAttribute = 'expires_at',
|
||||
$prefix = '')
|
||||
{
|
||||
$this->table = $table;
|
||||
$this->dynamo = $dynamo;
|
||||
$this->keyAttribute = $keyAttribute;
|
||||
$this->valueAttribute = $valueAttribute;
|
||||
$this->expirationAttribute = $expirationAttribute;
|
||||
|
||||
$this->setPrefix($prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an item from the cache by key.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
$response = $this->dynamo->getItem([
|
||||
'TableName' => $this->table,
|
||||
'ConsistentRead' => false,
|
||||
'Key' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
if (! isset($response['Item'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->isExpired($response['Item'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($response['Item'][$this->valueAttribute])) {
|
||||
return $this->unserialize(
|
||||
$response['Item'][$this->valueAttribute]['S'] ??
|
||||
$response['Item'][$this->valueAttribute]['N'] ??
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple items from the cache by key.
|
||||
*
|
||||
* Items not found in the cache will have a null value.
|
||||
*
|
||||
* @param array $keys
|
||||
* @return array
|
||||
*/
|
||||
public function many(array $keys)
|
||||
{
|
||||
$prefixedKeys = array_map(function ($key) {
|
||||
return $this->prefix.$key;
|
||||
}, $keys);
|
||||
|
||||
$response = $this->dynamo->batchGetItem([
|
||||
'RequestItems' => [
|
||||
$this->table => [
|
||||
'ConsistentRead' => false,
|
||||
'Keys' => collect($prefixedKeys)->map(function ($key) {
|
||||
return [
|
||||
$this->keyAttribute => [
|
||||
'S' => $key,
|
||||
],
|
||||
];
|
||||
})->all(),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$now = Carbon::now();
|
||||
|
||||
return array_merge(collect(array_flip($keys))->map(function () {
|
||||
})->all(), collect($response['Responses'][$this->table])->mapWithKeys(function ($response) use ($now) {
|
||||
if ($this->isExpired($response, $now)) {
|
||||
$value = null;
|
||||
} else {
|
||||
$value = $this->unserialize(
|
||||
$response[$this->valueAttribute]['S'] ??
|
||||
$response[$this->valueAttribute]['N'] ??
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
return [Str::replaceFirst($this->prefix, '', $response[$this->keyAttribute]['S']) => $value];
|
||||
})->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given item is expired.
|
||||
*
|
||||
* @param array $item
|
||||
* @param \DateTimeInterface|null $expiration
|
||||
* @return bool
|
||||
*/
|
||||
protected function isExpired(array $item, $expiration = null)
|
||||
{
|
||||
$expiration = $expiration ?: Carbon::now();
|
||||
|
||||
return isset($item[$this->expirationAttribute]) &&
|
||||
$expiration->getTimestamp() >= $item[$this->expirationAttribute]['N'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
$this->dynamo->putItem([
|
||||
'TableName' => $this->table,
|
||||
'Item' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
$this->valueAttribute => [
|
||||
$this->type($value) => $this->serialize($value),
|
||||
],
|
||||
$this->expirationAttribute => [
|
||||
'N' => (string) $this->toTimestamp($seconds),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store multiple items in the cache for a given number of $seconds.
|
||||
*
|
||||
* @param array $values
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function putMany(array $values, $seconds)
|
||||
{
|
||||
$expiration = $this->toTimestamp($seconds);
|
||||
|
||||
$this->dynamo->batchWriteItem([
|
||||
'RequestItems' => [
|
||||
$this->table => collect($values)->map(function ($value, $key) use ($expiration) {
|
||||
return [
|
||||
'PutRequest' => [
|
||||
'Item' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
$this->valueAttribute => [
|
||||
$this->type($value) => $this->serialize($value),
|
||||
],
|
||||
$this->expirationAttribute => [
|
||||
'N' => (string) $expiration,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
})->values()->all(),
|
||||
],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache if the key doesn't exist.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function add($key, $value, $seconds)
|
||||
{
|
||||
try {
|
||||
$this->dynamo->putItem([
|
||||
'TableName' => $this->table,
|
||||
'Item' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
$this->valueAttribute => [
|
||||
$this->type($value) => $this->serialize($value),
|
||||
],
|
||||
$this->expirationAttribute => [
|
||||
'N' => (string) $this->toTimestamp($seconds),
|
||||
],
|
||||
],
|
||||
'ConditionExpression' => 'attribute_not_exists(#key) OR #expires_at < :now',
|
||||
'ExpressionAttributeNames' => [
|
||||
'#key' => $this->keyAttribute,
|
||||
'#expires_at' => $this->expirationAttribute,
|
||||
],
|
||||
'ExpressionAttributeValues' => [
|
||||
':now' => [
|
||||
'N' => (string) Carbon::now()->getTimestamp(),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
return true;
|
||||
} catch (DynamoDbException $e) {
|
||||
if (Str::contains($e->getMessage(), 'ConditionalCheckFailed')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
*/
|
||||
public function increment($key, $value = 1)
|
||||
{
|
||||
try {
|
||||
$response = $this->dynamo->updateItem([
|
||||
'TableName' => $this->table,
|
||||
'Key' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
],
|
||||
'ConditionExpression' => 'attribute_exists(#key) AND #expires_at > :now',
|
||||
'UpdateExpression' => 'SET #value = #value + :amount',
|
||||
'ExpressionAttributeNames' => [
|
||||
'#key' => $this->keyAttribute,
|
||||
'#value' => $this->valueAttribute,
|
||||
'#expires_at' => $this->expirationAttribute,
|
||||
],
|
||||
'ExpressionAttributeValues' => [
|
||||
':now' => [
|
||||
'N' => (string) Carbon::now()->getTimestamp(),
|
||||
],
|
||||
':amount' => [
|
||||
'N' => (string) $value,
|
||||
],
|
||||
],
|
||||
'ReturnValues' => 'UPDATED_NEW',
|
||||
]);
|
||||
|
||||
return (int) $response['Attributes'][$this->valueAttribute]['N'];
|
||||
} catch (DynamoDbException $e) {
|
||||
if (Str::contains($e->getMessage(), 'ConditionalCheckFailed')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int|bool
|
||||
*/
|
||||
public function decrement($key, $value = 1)
|
||||
{
|
||||
try {
|
||||
$response = $this->dynamo->updateItem([
|
||||
'TableName' => $this->table,
|
||||
'Key' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
],
|
||||
'ConditionExpression' => 'attribute_exists(#key) AND #expires_at > :now',
|
||||
'UpdateExpression' => 'SET #value = #value - :amount',
|
||||
'ExpressionAttributeNames' => [
|
||||
'#key' => $this->keyAttribute,
|
||||
'#value' => $this->valueAttribute,
|
||||
'#expires_at' => $this->expirationAttribute,
|
||||
],
|
||||
'ExpressionAttributeValues' => [
|
||||
':now' => [
|
||||
'N' => (string) Carbon::now()->getTimestamp(),
|
||||
],
|
||||
':amount' => [
|
||||
'N' => (string) $value,
|
||||
],
|
||||
],
|
||||
'ReturnValues' => 'UPDATED_NEW',
|
||||
]);
|
||||
|
||||
return (int) $response['Attributes'][$this->valueAttribute]['N'];
|
||||
} catch (DynamoDbException $e) {
|
||||
if (Str::contains($e->getMessage(), 'ConditionalCheckFailed')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache indefinitely.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
return $this->put($key, $value, now()->addYears(5)->getTimestamp());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a lock instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $seconds
|
||||
* @param string|null $owner
|
||||
* @return \Illuminate\Contracts\Cache\Lock
|
||||
*/
|
||||
public function lock($name, $seconds = 0, $owner = null)
|
||||
{
|
||||
return new DynamoDbLock($this, $this->prefix.$name, $seconds, $owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore a lock instance using the owner identifier.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $owner
|
||||
* @return \Illuminate\Contracts\Cache\Lock
|
||||
*/
|
||||
public function restoreLock($name, $owner)
|
||||
{
|
||||
return $this->lock($name, 0, $owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function forget($key)
|
||||
{
|
||||
$this->dynamo->deleteItem([
|
||||
'TableName' => $this->table,
|
||||
'Key' => [
|
||||
$this->keyAttribute => [
|
||||
'S' => $this->prefix.$key,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all items from the cache.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
throw new RuntimeException('DynamoDb does not support flushing an entire table. Please create a new table.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UNIX timestamp for the given number of seconds.
|
||||
*
|
||||
* @param int $seconds
|
||||
* @return int
|
||||
*/
|
||||
protected function toTimestamp($seconds)
|
||||
{
|
||||
return $seconds > 0
|
||||
? $this->availableAt($seconds)
|
||||
: Carbon::now()->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the value.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
protected function serialize($value)
|
||||
{
|
||||
return is_numeric($value) ? (string) $value : serialize($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unserialize the value.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
protected function unserialize($value)
|
||||
{
|
||||
if (filter_var($value, FILTER_VALIDATE_INT) !== false) {
|
||||
return (int) $value;
|
||||
}
|
||||
|
||||
if (is_numeric($value)) {
|
||||
return (float) $value;
|
||||
}
|
||||
|
||||
return unserialize($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DynamoDB type for the given value.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
protected function type($value)
|
||||
{
|
||||
return is_numeric($value) ? 'N' : 'S';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cache key prefix.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cache key prefix.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @return void
|
||||
*/
|
||||
public function setPrefix($prefix)
|
||||
{
|
||||
$this->prefix = ! empty($prefix) ? $prefix.':' : '';
|
||||
}
|
||||
}
|
||||
46
vendor/laravel/framework/src/Illuminate/Cache/Events/CacheEvent.php
vendored
Normal file
46
vendor/laravel/framework/src/Illuminate/Cache/Events/CacheEvent.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache\Events;
|
||||
|
||||
abstract class CacheEvent
|
||||
{
|
||||
/**
|
||||
* The key of the event.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $key;
|
||||
|
||||
/**
|
||||
* The tags that were assigned to the key.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $tags;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $key
|
||||
* @param array $tags
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($key, array $tags = [])
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->tags = $tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags for the cache event.
|
||||
*
|
||||
* @param array $tags
|
||||
* @return $this
|
||||
*/
|
||||
public function setTags($tags)
|
||||
{
|
||||
$this->tags = $tags;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
28
vendor/laravel/framework/src/Illuminate/Cache/Events/CacheHit.php
vendored
Normal file
28
vendor/laravel/framework/src/Illuminate/Cache/Events/CacheHit.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache\Events;
|
||||
|
||||
class CacheHit extends CacheEvent
|
||||
{
|
||||
/**
|
||||
* The value that was retrieved.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param array $tags
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($key, $value, array $tags = [])
|
||||
{
|
||||
parent::__construct($key, $tags);
|
||||
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
8
vendor/laravel/framework/src/Illuminate/Cache/Events/CacheMissed.php
vendored
Normal file
8
vendor/laravel/framework/src/Illuminate/Cache/Events/CacheMissed.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache\Events;
|
||||
|
||||
class CacheMissed extends CacheEvent
|
||||
{
|
||||
//
|
||||
}
|
||||
8
vendor/laravel/framework/src/Illuminate/Cache/Events/KeyForgotten.php
vendored
Normal file
8
vendor/laravel/framework/src/Illuminate/Cache/Events/KeyForgotten.php
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache\Events;
|
||||
|
||||
class KeyForgotten extends CacheEvent
|
||||
{
|
||||
//
|
||||
}
|
||||
37
vendor/laravel/framework/src/Illuminate/Cache/Events/KeyWritten.php
vendored
Normal file
37
vendor/laravel/framework/src/Illuminate/Cache/Events/KeyWritten.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache\Events;
|
||||
|
||||
class KeyWritten extends CacheEvent
|
||||
{
|
||||
/**
|
||||
* The value that was written.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* The number of seconds the key should be valid.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
public $seconds;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int|null $seconds
|
||||
* @param array $tags
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($key, $value, $seconds = null, $tags = [])
|
||||
{
|
||||
parent::__construct($key, $tags);
|
||||
|
||||
$this->value = $value;
|
||||
$this->seconds = $seconds;
|
||||
}
|
||||
}
|
||||
270
vendor/laravel/framework/src/Illuminate/Cache/FileStore.php
vendored
Normal file
270
vendor/laravel/framework/src/Illuminate/Cache/FileStore.php
vendored
Normal file
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Cache;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Cache\Store;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\InteractsWithTime;
|
||||
|
||||
class FileStore implements Store
|
||||
{
|
||||
use InteractsWithTime, RetrievesMultipleKeys;
|
||||
|
||||
/**
|
||||
* The Illuminate Filesystem instance.
|
||||
*
|
||||
* @var \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
protected $files;
|
||||
|
||||
/**
|
||||
* The file cache directory.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $directory;
|
||||
|
||||
/**
|
||||
* Create a new file cache store instance.
|
||||
*
|
||||
* @param \Illuminate\Filesystem\Filesystem $files
|
||||
* @param string $directory
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Filesystem $files, $directory)
|
||||
{
|
||||
$this->files = $files;
|
||||
$this->directory = $directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an item from the cache by key.
|
||||
*
|
||||
* @param string|array $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
return $this->getPayload($key)['data'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of seconds.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @param int $seconds
|
||||
* @return bool
|
||||
*/
|
||||
public function put($key, $value, $seconds)
|
||||
{
|
||||
$this->ensureCacheDirectoryExists($path = $this->path($key));
|
||||
|
||||
$result = $this->files->put(
|
||||
$path, $this->expiration($seconds).serialize($value), true
|
||||
);
|
||||
|
||||
return $result !== false && $result > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the file cache directory if necessary.
|
||||
*
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
protected function ensureCacheDirectoryExists($path)
|
||||
{
|
||||
if (! $this->files->exists(dirname($path))) {
|
||||
$this->files->makeDirectory(dirname($path), 0777, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Increment the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int
|
||||
*/
|
||||
public function increment($key, $value = 1)
|
||||
{
|
||||
$raw = $this->getPayload($key);
|
||||
|
||||
return tap(((int) $raw['data']) + $value, function ($newValue) use ($key, $raw) {
|
||||
$this->put($key, $newValue, $raw['time'] ?? 0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement the value of an item in the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return int
|
||||
*/
|
||||
public function decrement($key, $value = 1)
|
||||
{
|
||||
return $this->increment($key, $value * -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store an item in the cache indefinitely.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function forever($key, $value)
|
||||
{
|
||||
return $this->put($key, $value, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function forget($key)
|
||||
{
|
||||
if ($this->files->exists($file = $this->path($key))) {
|
||||
return $this->files->delete($file);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all items from the cache.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
if (! $this->files->isDirectory($this->directory)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->files->directories($this->directory) as $directory) {
|
||||
if (! $this->files->deleteDirectory($directory)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an item and expiry time from the cache by key.
|
||||
*
|
||||
* @param string $key
|
||||
* @return array
|
||||
*/
|
||||
protected function getPayload($key)
|
||||
{
|
||||
$path = $this->path($key);
|
||||
|
||||
// If the file doesn't exist, we obviously cannot return the cache so we will
|
||||
// just return null. Otherwise, we'll get the contents of the file and get
|
||||
// the expiration UNIX timestamps from the start of the file's contents.
|
||||
try {
|
||||
$expire = substr(
|
||||
$contents = $this->files->get($path, true), 0, 10
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return $this->emptyPayload();
|
||||
}
|
||||
|
||||
// If the current time is greater than expiration timestamps we will delete
|
||||
// the file and return null. This helps clean up the old files and keeps
|
||||
// this directory much cleaner for us as old files aren't hanging out.
|
||||
if ($this->currentTime() >= $expire) {
|
||||
$this->forget($key);
|
||||
|
||||
return $this->emptyPayload();
|
||||
}
|
||||
|
||||
try {
|
||||
$data = unserialize(substr($contents, 10));
|
||||
} catch (Exception $e) {
|
||||
$this->forget($key);
|
||||
|
||||
return $this->emptyPayload();
|
||||
}
|
||||
|
||||
// Next, we'll extract the number of seconds that are remaining for a cache
|
||||
// so that we can properly retain the time for things like the increment
|
||||
// operation that may be performed on this cache on a later operation.
|
||||
$time = $expire - $this->currentTime();
|
||||
|
||||
return compact('data', 'time');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a default empty payload for the cache.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function emptyPayload()
|
||||
{
|
||||
return ['data' => null, 'time' => null];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full path for the given cache key.
|
||||
*
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
protected function path($key)
|
||||
{
|
||||
$parts = array_slice(str_split($hash = sha1($key), 2), 0, 2);
|
||||
|
||||
return $this->directory.'/'.implode('/', $parts).'/'.$hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expiration time based on the given seconds.
|
||||
*
|
||||
* @param int $seconds
|
||||
* @return int
|
||||
*/
|
||||
protected function expiration($seconds)
|
||||
{
|
||||
$time = $this->availableAt($seconds);
|
||||
|
||||
return $seconds === 0 || $time > 9999999999 ? 9999999999 : $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Filesystem instance.
|
||||
*
|
||||
* @return \Illuminate\Filesystem\Filesystem
|
||||
*/
|
||||
public function getFilesystem()
|
||||
{
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the working directory of the cache.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDirectory()
|
||||
{
|
||||
return $this->directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cache key prefix.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
21
vendor/laravel/framework/src/Illuminate/Cache/LICENSE.md
vendored
Normal file
21
vendor/laravel/framework/src/Illuminate/Cache/LICENSE.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Taylor Otwell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user