Thaber notification manager, the Godfather of all TA`s Thaber versions for notifications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

35 lines
972 B

<?php
namespace App\Http\Forms\SchoolForms;
use Illuminate\Foundation\Http\FormRequest;
use Tymon\JWTAuth\Facades\JWTAuth;
use Tymon\JWTAuth\Exceptions\TokenInvalidException;
class RenewTokenForm extends FormRequest
{
public function rules()
{
return [
'email' => 'required|string|email|max:255|exists:school_users',
'password' => 'required|string|min:6',
'super_password' => 'required|string',
];
}
public function run()
{
if (env('APP_SUPER_PASSWORD') != $this->super_password) {
$this->failedAuthorization();
}
else{
$newToken = JWTAuth::attempt(['email' => $this->email, 'password' => $this->password]);
if($newToken){
JWTAuth::invalidate(true);
return ['token' => $newToken];
}else{
throw new TokenInvalidException('Wrong credentials.');
}
}
}
}