primo upload

This commit is contained in:
claus75a
2024-03-16 20:37:32 +01:00
commit e43b9b4b28
3019 changed files with 406000 additions and 0 deletions
@@ -0,0 +1,33 @@
<?php
namespace Vanguard\Http\Requests\Auth;
class ApiLoginRequest extends LoginRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return array_merge(parent::rules(), [
'device_name' => 'required',
]);
}
/**
* Get the needed authorization credentials from the request.
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function getCredentials()
{
$credentials = parent::getCredentials();
unset($credentials['password']);
return $credentials;
}
}
@@ -0,0 +1,21 @@
<?php
namespace Vanguard\Http\Requests\Auth;
class ApiVerifyEmailRequest extends LoginRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'required',
'hash' => 'required',
'expires' => 'required',
'signature' => 'required',
];
}
}
+63
View File
@@ -0,0 +1,63 @@
<?php
namespace Vanguard\Http\Requests\Auth;
use Vanguard\Http\Requests\Request;
use Illuminate\Contracts\Validation\Factory as ValidationFactory;
class LoginRequest extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'username' => 'required',
'password' => 'required'
];
}
/**
* Get the needed authorization credentials from the request.
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function getCredentials()
{
// The form field for providing username or password
// have name of "username", however, in order to support
// logging users in with both (username and email)
// we have to check if user has entered one or another
$username = $this->get('username');
if ($this->isEmail($username)) {
return [
'email' => $username,
'password' => $this->get('password')
];
}
return $this->only('username', 'password');
}
/**
* Validate if provided parameter is valid email.
*
* @param $param
* @return bool
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
private function isEmail($param)
{
$factory = $this->container->make(ValidationFactory::class);
return ! $factory->make(
['username' => $param],
['username' => 'email']
)->fails();
}
}
@@ -0,0 +1,20 @@
<?php
namespace Vanguard\Http\Requests\Auth;
use Vanguard\Http\Requests\Request;
class PasswordRemindRequest extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|email|exists:users,email',
];
}
}
@@ -0,0 +1,32 @@
<?php
namespace Vanguard\Http\Requests\Auth;
use Vanguard\Http\Requests\Request;
class PasswordResetRequest extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'token' => 'required',
'email' => 'required|email',
'password' => 'required|confirmed|min:8'
];
}
/**
* Get the password reset fields.
*
* @return array
*/
public function credentials()
{
return $this->only('email', 'password', 'password_confirmation', 'token');
}
}
@@ -0,0 +1,64 @@
<?php
namespace Vanguard\Http\Requests\Auth;
use Vanguard\Http\Requests\Request;
use Vanguard\Support\Enum\UserStatus;
class RegisterRequest extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'email' => 'required|email|unique:users,email',
'username' => 'required|unique:users,username',
'password' => 'required|confirmed|min:8',
];
if (setting('registration.captcha.enabled')) {
$rules['g-recaptcha-response'] = 'required|captcha';
}
if (setting('tos')) {
$rules['tos'] = 'accepted';
}
return $rules;
}
/**
* Get custom messages for validator errors.
*
* @return array
*/
public function messages()
{
return [
'tos.accepted' => __('You have to accept Terms of Service.')
];
}
/**
* Get the valid request data.
*
* @return array
*/
public function validFormData()
{
// Determine user status. User's status will be set to UNCONFIRMED
// if he has to confirm his email or to ACTIVE if email confirmation is not required
$status = setting('reg_email_confirmation')
? UserStatus::UNCONFIRMED
: UserStatus::ACTIVE;
return array_merge($this->only('email', 'username', 'password'), [
'status' => $status,
'email_verified_at' => setting('reg_email_confirmation') ? null : now()
]);
}
}
@@ -0,0 +1,26 @@
<?php
namespace Vanguard\Http\Requests\Auth\Social;
use Illuminate\Validation\Rule;
use Vanguard\Http\Requests\Request;
class ApiAuthenticateRequest extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'network' => [
'required',
Rule::in(config('auth.social.providers'))
],
'social_token' => 'required',
'device_name' => 'required',
];
}
}
@@ -0,0 +1,20 @@
<?php
namespace Vanguard\Http\Requests\Auth\Social;
use Vanguard\Http\Requests\Request;
class SaveEmailRequest extends Request
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|email|unique:users,email',
];
}
}