Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

sanctum auth check?

auth('sanctum')->check();
Comment

laravel sanctum

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

laravel sanctum

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

laravel sanctum Provoking tokens

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

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

sanctum laravel

composer require laravel/sanctum
Comment

laravel sanctum issue token

use IlluminateHttpRequest;

Route::post('/tokens/create', function (Request $request) {
    $token = $request->user()->createToken($request->token_name);

    return ['token' => $token->plainTextToken];
});
Comment

sanctum laravel github

php artisan vendor:publish --provider="LaravelSanctumSanctumServiceProvider"
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

laravel sanctum api

<?php
    public function login(Request $request)
    {
        if(Auth::attempt(['email' => $request->email, 'password' => $request->password])){ 
            $user = Auth::user(); 
            $success['token'] =  $user->createToken('MyApp')->plainTextToken; 
            $success['name'] =  $user->name;
   
            return $this->sendResponse($success, 'User login successfully.');
        } 
        else{ 
            return $this->sendError('Unauthorised.', ['error'=>'Unauthorised']);
        } 
    }
}
Comment

PREVIOUS NEXT
Code Example
Shell :: bash read file into array 
Shell :: capacitor-google-auth 
Shell :: bash array number range from var 
Shell :: mac send terminal output to clipboard 
Shell :: phoenix install 
Shell :: install mongodb ubuntu 18.04 
Shell :: fork git ubuntu 
Shell :: vs code remote branch not showing 
Shell :: recover git stash clear 
Shell :: how to open windows powershell 
Shell :: install zeek on ubuntu 18.04 
Shell :: deploy a static website to heroku 
Shell :: bash cd || exit 
Shell :: How to remove every other line with sed? 
Shell :: win terminal turn off screen 
Shell :: how to move file from one directory to another in linux 
Shell :: git local branch track remote 
Shell :: git worktree prune 
Shell :: rpi install kodi 
Shell :: create a new repository on the command line 
Shell :: sed commands 
Shell :: how to move files that begine with uppercase in linux 
Shell :: pull file from specific commit git 
Shell :: run command every hour linux 
Shell :: conda install version 
Shell :: install ghost 
Shell :: chown recursive 
Shell :: deploy to firebase using trivis 
Shell :: how to use usb 3 with virtualbox 
Shell :: apt install package version 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =