认证网络应用

安装: 1

依赖项: 0

建议者: 0

安全: 0

星星: 0

观察者: 2

分支: 0

开放问题: 0

类型:项目

1.0.0 2021-11-14 04:37 UTC

This package is auto-updated.

Last update: 2024-09-14 10:56:03 UTC


README

简介

项目auth是为了使基于PHP的项目中的认证过程更容易而开发的。如果您想添加基于mariadb或mysql的认证,可以使用此项目。我们正在开发openauth、smtp、imap和LDAP认证,并将它们包含在项目的后续版本中。我们也欢迎PHP社区的提议和支持。您可以通过电子邮件optiwari.india@gmail.com联系我,我的邮件回复时间为24小时。

先决条件

PHP版本

此项目是在PHP-8.0.12上开发和测试的,尽管它预期在PHP-7.0+环境下无需任何更改即可正常运行。

依赖项

数据库

此项目使用mariadb-10.3.21开发,尽管它预期也能在mariadb-5.0.0和mysql-5.0.0上运行。

扩展

php-mysqli或php-mysqlnd

Composer

Composer是PHP中依赖项管理的工具。它允许您声明项目依赖的库,并将为您安装(更新)它们。您可以通过访问Composer网站下载、安装并了解更多关于Composer的信息。

入门

安装

打开您的项目目录并运行以下命令

composer require optiwariindia/auth

初始化

<?php 

include "vendor/autoload.php";

    //Please update Database details as per your database provider.
$db=[
    "host"=>"localhost",
    "user"=>"root",
    "pass"=>"",
    "name"=>"authdb"
];

optiwariindia\auth::config($db);

optiwariindia\auth::init();

if(optiwariindia\auth::isLoggedIn()){

    //Action when user is logged in

}else{

    //Action when user is not logged in

} 

登录

// Redirect path on successful login

optiwariindia\auth::dashboard("/dashboard");

/* Variables in Login form:
*   user:text
*   pass:text
*   Method: Post
*/

$resp=optiwariindia\auth::login();

/* Response:
*   status:success/error
*   error:error message if any
*/

注销

optiwariindia\auth::logout();

/* Response:
*   status:success/error
*   error:error message if any
*  redirects to home page on success
*/

注册

optiwariindia\auth::register($user,$pass,$name,$email,$phone);

/* Response:
*   status:success/error
*   error:error message if any
*   message:success message if any
*/

忘记密码

optiwariindia\auth::forgotPassword($user,$email,$phone);

/* Response:
*  returns One Time Password if user/email/phone exists
*  returns false if user/email/phone does not exists
*/

更新密码

optiwariindia\auth::updatePassword($user,$pass,$npass,$otp);

/* Response:
*  returns true if password updated successfully
*  returns error message if password not updated
*/

列出用户

optiwariindia\auth::listUsers();

/* Response:
*  returns array of users
*/

删除用户

optiwariindia\auth::delete($id);

/* Response:
*  returns true if user deleted successfully
*  returns error message if user not deleted
*/

获取用户详情

optiwariindia\auth::getUser($user);

optiwariindia\auth::getUserByID($id);

/* Response:
*  returns array of user details
*/