Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

install sanctum

composer require laravel/sanctum

php artisan vendor:publish --provider="LaravelSanctumSanctumServiceProvider"

php artisan migrate


"!!!!!!Next, if you plan to utilize Sanctum to authenticate an SPA, you should add Sanctum's middleware to your api middleware group within your application's app/Http/Kernel.php file:!!!!!"
'api' => [
    LaravelSanctumHttpMiddlewareEnsureFrontendRequestsAreStateful::class,
    'throttle:api',
    IlluminateRoutingMiddlewareSubstituteBindings::class,
],
Comment

laravel sanctum

//install
composer require laravel/sanctum
  
// vendor
php artisan vendor:publish --provider="LaravelSanctumSanctumServiceProvider"
Comment

laravel sanctum

Broadcast::routes(['middleware' => ['auth:sanctum']]);
Comment

sanctum laravel

composer require laravel/sanctum
Comment

laravel sanctum

return $user->createToken('token-name', ['server:update'])->plainTextToken;
Comment

laravel sanctum

use AppModelsSanctumPersonalAccessToken;
use LaravelSanctumSanctum;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
}
Comment

laravel sanctum

use IlluminateHttpRequest;

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});
Comment

laravel sanctum

axios.defaults.withCredentials = true;
Comment

laravel sanctum

use LaravelSanctumHasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;
}
Comment

laravel sanctum

// Revoke all tokens...
$user->tokens()->delete();

// Revoke the token that was used to authenticate the current request...
$request->user()->currentAccessToken()->delete();

// Revoke a specific token...
$user->tokens()->where('id', $tokenId)->delete();
Comment

laravel sanctum

if ($user->tokenCan('server:update')) {
    //
}
Comment

laravel sanctum

axios.get('/sanctum/csrf-cookie').then(response => {
    // Login...
});
Comment

laravel sanctum

use LaravelSanctumPersonalAccessToken as SanctumPersonalAccessToken;

class PersonalAccessToken extends SanctumPersonalAccessToken
{
    // ...
}
Comment

laravel sanctum

foreach ($user->tokens as $token) {
    //
}
Comment

laravel sanctum

return $request->user()->id === $server->user_id &&
       $request->user()->tokenCan('server:update')
Comment

laravel sanctum

'domain' => '.domain.com',
Comment

PREVIOUS NEXT
Code Example
Shell :: new ip linux 
Shell :: openvpn client docker 
Shell :: iptables linux 
Shell :: how to skip .pyc file adding into github repository 
Shell :: how to move wsl storage 
Shell :: how to convert 30fps to 60fps using ffmpeg 
Shell :: change php version devilbox 
Shell :: upload file via terminal 
Shell :: powershell add line to text file 
Shell :: webdev: command not found 
Shell :: how to download files from linux server 
Shell :: bash increment variable in while loop 
Shell :: find command path 
Shell :: snap powershell 
Shell :: print batch 
Shell :: Start Apache service FreeBSD 
Shell :: install pup command mac 
Shell :: spaceship theme zsh 
Shell :: command to return to old shell 
Shell :: how to print array bash 
Shell :: ubuntu install safari browser terminal 
Shell :: maven homebrew 
Shell :: .aws directory not found 
Shell :: linux list recursive 
Shell :: keycloak docker disable https 
Shell :: get container config docker 
Shell :: npm warn 
Shell :: linux remove packages 
Shell :: Mongodb admin login 
Shell :: nvmrc 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =