m1guelpf/laravel-fastlogin 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

m1guelpf/laravel-fastlogin

最新稳定版本:v2.2

Composer 安装命令:

composer require m1guelpf/laravel-fastlogin

包简介

Allow your users to login with FaceID/TouchID

README 文档

README

Latest Version on Packagist Total Downloads

Allow your users to register physical authentication devices (FaceID or TouchID on iPhones & macs, fingerprint on Android, Hello on Windows and USB keys) to skip entering their login credentials.

Installation

You can install the package via composer:

composer require m1guelpf/laravel-fastlogin

You'll then need to add the \M1guelpf\FastLogin\Models\Concerns\CanFastLogin trait to your user model and migrate your database by running php artisan migrate.

class User extends Authenticatable { use CanFastLogin; }

Usage

This package takes care of everything you need on the backend. To make our life easier on the frontend, we'll be using @web-auth/webauthn-helper and js-cookie. You can install them by running yarn add @web-auth/webauthn-helper js-cookie.

To get started, you need to have the user register a new credential. You can do so by presenting them with a modal when they login, or by adding the option to their settings page.

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 an user-generated event (like a "click" event).

import Cookies from 'js-cookie' import { useRegistration } from '@web-auth/webauthn-helper' const onClick = () => { const token = Cookies.get('XSRF-TOKEN') useRegistration({ actionUrl: route('fastlogin.create'), optionsUrl: route('fastlogin.create.details'), actionHeader: { 'x-xsrf-token': token }, }, { 'x-xsrf-token': token })().then(() => { // credential has been added }) }

Then, on the login page, you should check if the user has a credential saved (you can do so by calling the $request->hasCredential() method) and, if so, displaying a button to sign in using FastLogin.

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

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() }) }

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 12.09k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1000
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1000
  • Watchers: 18
  • Forks: 84
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固