coolcode/authapi 问题修复 & 功能扩展

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

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

coolcode/authapi

最新稳定版本:v1.0.0

Composer 安装命令:

composer require coolcode/authapi

包简介

api authentication using sanctum

README 文档

README

coolcode/authapi is a Laravel package that simplifies API authentication using Laravel Sanctum. This package provides a set of endpoints for user registration, login, and logout functionality with token-based authentication.

Installation

  1. Install the package via Composer:

    composer require coolcode/authapi
  2. Publish the Sanctum migrations:

    php artisan vendor:publish --tag=sanctum-migrations
  3. Run the migrations:

    php artisan migrate
  4. Finally, issue your Laravel Sanctum tokens when users authenticate with your API.

API Endpoints

1. Register

Endpoint: /api/register
Method: POST
Headers:

  • Accept: application/json
  • Content-Type: application/json

Request Body (form-data):

Key Value Type
name test text
email test@gmail.com text
password password text
confirm_password password text

Description:
Registers a new user in the system.

2. Login

Endpoint: /api/login
Method: POST
Headers:

  • Accept: application/json
  • Content-Type: application/json

Request Body (form-data):

Key Value Type
email test@gmail.com text
password password text

Description:
Authenticates the user and issues a Bearer token for future API requests. The token is stored in the environment variable token.

3. Logout

Endpoint: /api/logout
Method: POST
Headers:

  • Accept: application/json
  • Content-Type: application/json
  • Authorization: Bearer {{token}}

Description:
Logs the authenticated user out and invalidates the Bearer token.

Usage

Once you've installed the package and set it up, you can use these endpoints in your Postman collection or any API client to handle user authentication.

Postman Example

  1. Register a user using the Register API.
  2. Login using the Login API to get the Bearer token.
  3. Set the token in your environment variables for future authenticated requests.
  4. Logout the user using the Logout API.

License

This package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固