0
  • JavaScript
  • Laravel
  • Linux
  • PHP
  • Servers
  • Vue
  • Web 3
    • Solidity
  • More
    • CSS
    • Database
      • MongoDB
      • SQL
    • Linux Commands
    • Programming
    • Python
    • WordPress
  • Contact
Laramatic
Laramatic
Laramatic
  • JavaScript
  • Laravel
  • Linux
  • PHP
  • Servers
  • Vue
  • Web 3
    • Solidity
  • More
    • CSS
    • Database
      • MongoDB
      • SQL
    • Linux Commands
    • Programming
    • Python
    • WordPress
  • Contact
Laramatic
  • JavaScript
  • Laravel
  • Linux
  • PHP
  • Servers
  • Vue
  • Web 3
    • Solidity
  • More
    • CSS
    • Database
      • MongoDB
      • SQL
    • Linux Commands
    • Programming
    • Python
    • WordPress
  • Contact
LaravelPHP

Laravel – Add FaceID And TouchID Login Apps

July 2, 2021 2 Min Read

There is a new and existing package which allows users to register physical authentication devices (FaceID or TouchID on iPhones and Macs, Fingerprints on Android, Hello on Windows and USB keys). This will save their time and effort to enter credentials. Because, no one wants to enter credentials anymore, I mean are we living in caves?

So after installing Laravel we have to run this composer command.

composer require m1guelpf/laravel-fastlogin

Then add \M1guelpf\FastLogin\Models\Concerns\HasFastLogin trait into you User Model like this.

class User extends Authenticatable
{
    use CanFastLogin;
}

Now after taking care of everything on backend, lets talk about front end. We need to run this command in terminal.

yarn add @web-auth/webauthn-helper js-cookie

This will add packages like @web-auth/webauthn-helper and js-cookie in your app. Now you need this code to make things work.

import Cookies from 'js-cookie'
import { useLogin } from '@web-auth/webauthn-helper'
const onClick = () => {
    const token = Cookies.get('XSRF-TOKEN')
    useLogin({
        actionUrl: route('fastlogin.login'),
        optionsUrl: route('fastlogin.login.details'),
        actionHeader: {
            'x-xsrf-token': token
        },
    }, {
        'x-xsrf-token': token
    })().then(() => {
        // the user has been logged in
        window.location.reload()
    })
}

So after having done that, we hope the users of your Laravel app will never require to enter credentials like ancient web culture days.

Note: Due to Apple’s restrictions, you can only call the creation function after a user gesture, that is, the function needs to be invoked in the user-generated event (like a “click” event).

Learn Laravel, React, VueJS and Python
read programming books
Tags: faceId laravel login touchId
Shares
Share on Facebook Share on Twitter Share on Pinterest Share on WhatsApp Share on WhatsApp Share on Reddit Share on Email

Popular Tutorials/Posts

How to Implement Dynamic AutoComplete Search in Laravel 9 Using Select 2 JS

How To Disable or Enable Text Selection Using CSS on Any Web Page?

Vite 6 – The Latest Release Review & Use Cases With Code Examples

How to Logout Multiple Login Sessions From Multiple Devices Browsers in Laravel 10

Linux Commands

Cairo-dock Installation On A Debian, Ubuntu, Arch, Kali, Fedora And Raspbian

Relion_tiltpair_plot

Install Replmarks On A Debian, Ubuntu And Raspbian

Install Icont On A Debian, Ubuntu, Kali And Raspbian

Subscribe to Our Newsletter
Get the latest tutorials and guides delivered directly in your inbox.

You Might also Enjoy

Laravel

New & Improved React V19 Step-by-Step Guide with Practical Code Examples

December 13, 2024
Laravel

How To Implement A Sign-In System Using QR Codes With Laravel And Livewire

November 28, 2024
Laravel

Here is How Code Generation Works in Rust C++ & Laravel With Code Examples

October 25, 2024
Laravel

How To Install Laravel & PHP With A Single Command

October 16, 2024
Load More
© Copyright 2023 Laramatic. All Laravel, React, VueJS, PHP, MySQL, Linux, and more tutorials are contributed by writers. If you are interested in publishing your tutorial get in touch.

Our website uses cookies to improve your experience. Learn more about: cookie policy

Accept