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

JavaScript Scope – What is Scope in JavaScript?

How to Implement Unions with Query Builder in Laravel?

How to Use Seeder in Laravel to Populate Database?

How to Install MongoDB on a Mac?

Linux Commands

How To Install Sha1map.toml On Debian, Ubuntu, Alpine, Arch, Kali, Fedora And Raspbian?

Lldb-mi-3.8.1-3.8 Command

Sphinx3_livepretend Command

Dnscrypt-wrapper

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

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

December 11, 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
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