PATH:
home
/
rwabteecom
/
project_11
/
app
/
Services
/
Authentication
/
Editing: AuthenticationServices.php
<?php namespace App\Services\Authentication; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\RateLimiter; use Illuminate\Validation\ValidationException; class AuthenticationServices extends BaseAuthenticationService { protected $request; protected $auth; public function __construct($request, $auth) { $this->request = $request; $this->auth = new $auth(); } public function authenticate() { $this->ensureIsNotRateLimited(); $auth = $this->auth->where('phone', $this->request->string("phone")->toString())->first(); if (!$auth) { RateLimiter::hit($this->throttleKey()); throw ValidationException::withMessages([ "auth" => __('auth.failed') ]); } if (!Hash::check($this->request->string('password')->toString(), $auth->password)) { RateLimiter::hit($this->throttleKey()); throw ValidationException::withMessages([ "password" => __('auth.failed') ]); } RateLimiter::clear($this->throttleKey()); $auth->update([ "device_token" => $this->request->string('device_token')->toString(), ]); $auth->tokens()->delete(); return $auth; } }
SAVE
CANCEL