Skip to content

emka.web.id

writing knowledge, recording civilization

Menu
  • Home
  • Tutorial
  • Search
Menu

Butuh Fitur OTP di Aplikasi Laravel? Pakai Ini!

Posted on February 8, 2025

OTPZ adalah sebuah paket Laravel yang dibuat oleh Ben Bjurstrom (pembuat Prezet) yang menyediakan kata sandi sekali pakai (OTP) faktor pertama yang aman untuk aplikasi Laravel. Ini memungkinkan pengguna untuk memasukkan alamat email mereka dan menerima kode sekali pakai untuk masuk, sebagai ganti kata sandi.

Fitur Utama

  • Pembatasan Laju
  • Waktu kedaluwarsa yang dapat dikonfigurasi
  • Membatalkan OTP setelah penggunaan pertama
  • Mengunci OTP ke sesi pengguna
  • Membatalkan OTP setelah terlalu banyak percobaan gagal
  • Melihat pesan kesalahan yang detail
  • Kustomisasi templat email yang digunakan
  • Log yang dapat diaudit

Untuk pengaturan, instal paket melalui Composer:

Bash

composer require benbjurstrom/otpz

Kemudian publikasikan dan jalankan migrasi yang disertakan:

Bash

php artisan vendor:publish --tag="otpz-migrations"
php artisan migrate

Selanjutnya, tambahkan antarmuka dan trait paket ini ke model User Authenticatable Anda

PHP

<?php
// app/Models/User.php
namespace App\Models;

//...
use BenBjurstrom\Otpz\Models\Concerns\HasOtps;
use BenBjurstrom\Otpz\Models\Concerns\Otpable;

class User extends Authenticatable implements Otpable
{
    use HasFactory, Notifiable, HasOtps;

    // ...
}

Dan terakhir tambahkan rute yang disediakan oleh paket ini dalam file routes/web.php Anda:

PHP

Route::otpRoutes();

Secara opsional, Anda dapat mempublikasikan tampilan dan konfigurasi bawaan untuk lebih lanjut melakukan kustomisasi:

Bash

php artisan vendor:publish --tag="otpz-views"
php artisan vendor:publish --tag="otpz-config"

Paket ini bekerja dengan Laravel Breeze baik dengan Livewire maupun Inertia, dan petunjuk lebih lanjut disediakan tentang cara memperbarui metode LoginRequest::authenticate masing-masing dengan metode send email untuk menjalankan action SendOtp.

Jika Anda mencari cara cepat untuk memberikan pengguna akses yang aman dan sementara atau sekali pakai ke sistem, maka OTPZ mungkin adalah paket yang Anda cari.

Pelajari lebih lanjut tentang paket ini dan lihat kode sumbernya di GitHub.

Terbaru

  • Worth It! Switching from Fedora KDE to Kubuntu
  • I’m Happy Using ‘Herdr’, The Fastest Growing Devtool written in Rust
  • Testing Goose on Omarchy Linux (App & CLI): The Open-Source Solution for Daily Task Automation
  • GNOME Founder Attacks Omarchy Founder as “Lazy, Racist, Ignorant”
  • Why I Stopped Using Plain Command Line Docker and Use Portainer 3.0 To Make My Home Projects Fun Again
  • Why I Switched to a Proper Firewall Box with OPNSense for My Homelab Stuff
  • Fixing Windows Error 0x80070005 Hyper-V Export Access Denied Error the Right Way
  • Fixing Hyper V Export Errors and Building a Better Virtual Machine Setup (error 0x80070002, 0x80070005)
  • Fixing the Dreaded Windows Audio Service Stuck on Stopping Error
  • Windows SIM Error, Unknown error 0xc1420127
  • How I’m Building a Cat Breeding Management App with Python Qt6 + Microsoft Litebox, in 1 Week
  • Why Windows Keeps Nuking Your GPU Drivers (And How to Take Back Control)
  • Why I Finally Ditched Mainstream Windows Cleaners (And Why I Use ‘Kudu’ Instead)
  • AI Made Everything Faster, Including Bad Decisions
  • Raspberry Pi Desktop Available of PC and Mac, Based on Debian 13
  • Why I Stopped Yelling at My PC When Error; Getting Windows 11 Voice Isolation and Access to Actually Work
  • Berobat Kanker ke Malaysia: Berapa Biayanya dan Apa Saja yang Perlu Disiapkan?
  • Stop Sending Every Prompt to the Biggest AI Model You Can Find
  • Stop Building AI Agents from Scratch: My Pick for the Best Native Windows Setup
  • Jev Is Faster and Cheaper, But I Still Recommend Clef. Here’s Why.
  • Weird XCP-NG Bug or Feature? Enable Maintenance Mode = Host Not Enough Memory
  • Vinix OS: Another OS That Want to Beat Linux, Try it!
  • Trying NVX, An Ultra-Light Micro-VM Sandbox from Microsoft
  • Learning NocoDB from Scratch: Creating a Simple Greenhouse App
  • How RHEL 10.2 Quietly Turned Into an Absolute Security Beast
  • Grab Videos from Anywhere with ReClip (Can Running Locally)
  • Jumped onto Ubuntu 26.04 LTS? Here’s How to Add a New User Account
  • Tutorial Cara Install WPS Office di Linux (Alternatif Microsoft Office)
  • Tutorial Upgrade Server Ubuntu 24.04 LTS ke Ubuntu 26.04 LTS dengan Aman
  • Inilah Alasan kenapa akun TikTok dibatasi tidak bisa klaim koin dan masalah pembatasan lainnya?
  • Canonical: Ubuntu coming soon to Snapdragon X2 Series platforms
  • Finally, wolfSSL adds post-quantum algorithms!
  • How to Run Gemma Embedding Models Using Docker
  • Deploy Nginx Rootful Container with Podman
  • How to Sandboxing Browser on Linux Desktop with Flatpak
  • Building Long-Running AI Agents with Pi Durable: An AI SRE Agent Example
  • Prompt AI: Impressionist Portrait Art of a Woman
  • Prompt AI: Stylish Man Walking Double Exposure Photo
  • Trying Nemotron 3.5 Super VL: NVIDIA’s Open Multimodal Model Built for Agents That Actually See and Act
  • Pruna AI Release their Qwen-Image 2.1 LoRA Adapter, 6x Faster than Regular Qwen
  • Ini Dia QR Link Dana Kaget 400K, 27 Oktober 2026
  • Fresh! Ini Biodata dan Fakta Unik dari Member No Na
  • Inilah Rekomendasi 10 Drama Jepang Wajib Tonton November 2026
  • Siapa Sosok Dibalik Video Kerudung Biru Di Mobil? Ini Konteks Asli Rekamannya
  • Bantah Menteri Kesehatan Sesak Nafas di Kalimantan, Netizen Tidak Percaya

©2026 emka.web.id | Design: Newspaperly WordPress Theme