承接 hotworks/user-validation 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

hotworks/user-validation

Composer 安装命令:

composer create-project hotworks/user-validation

包简介

User validation class

README 文档

README

Author: Rui Cunha
Email: r.cunha@datagen.eu

About this project

This class aims to provide a complete set of resources to handle:

  • Registration and validation of new users
  • Login of existing users
  • Reseting forgotten passwords It features:
  • A method to create the required table structure
  • Passworh hashing
  • Token secured validation
  • Methods to include the bundled forms in your HTML code
How to set it up

Include the file validation.php, if you are not using composer. If you are using composer, just type:

composer require hotworks/user-validation
  1. Copy the four forms to a destination of your choice, you will be providing their path later.
  2. Create the user table on your database. You have a method for this in the class:
    $validation=new UserValidation();
    $validation->databaseConnectionRW = $myPdoConnectionObject ;
    $validation->createUserDatabase();
    
How to display the forms

The class has a property for the path of each one of the forms:

public string $pathToValidationForm;
public string $pathToForgotPasswordForm;
public string $pathToRegistrationForm;
public string $pathToPasswordResetForm;

It also has a method that returns the HTML markup of each form:

public function getValidationForm(){...};
public function getForgotPasswordForm(){...};
public function getRegistrationForm(){...};
public function getResetPasswordForm(){...};

To access the html, provide the path and call the method:

$validation=new UserValidation();
$validation->pathToValidationForm = "/path/to/my/validation/form";
$form=$validation-> getValidationForm();
echo $form;
How to handle the posted data

When the forms are submited, data is posted to the server.

Creating a new user

$validation=new UserValidation();
$validation->email = $_POST['email'];
$validation->password = $_POST['password'];
$validation->passwordConfirmation = $_POST['passwordConfirmation'];
$result = $validation->createNewUser();
/*
If the user is created, $result will contain a key and a token. You need to build a URL with them and email it to your user, so that he can validate his new account.
*/

Triggering the new account validation

$validation=new UserValidation();
$validation->email = $_GET['email'];
$validation->validationKey = $_GET['key'];
$validation->validationToken = $_GET['token'];
$result=$validation->activateNewAccount();

Loging an existing user

$validation=new UserValidation();
$validation->email = $_POST['email'];
$validation->password = $_POST['password'];
$result = $validation->validateLoginData();

Accessing the password reset request form

This one has a detail: you need to provide the email via the 'email' property. The key and token that will be generated within the form will depend on this.

$validation=new UserValidation();
$validation->email = $_GET['emailForgotPassword'];
$validation->pathToPasswordResetForm = "/path/to/my/password/reset/form";
form = $validation->getResetPasswordForm();
echo $form;
/*
This form will contain hidden key and token that will be posted as well.
*/

Handling the password reset request form data

$validation=new UserValidation();
$validation->email = $_POST['emailResetPassword'];
$validation->password = $_POST['password'];
$validation->passwordConfirmation = $_POST['passwordConfirmation'];
$validation->validationKey = $_POST['validationKey'];
$validation->validationToken = $_POST['validationToken'];
$result=$validation->validateForgotPasswordData();
/*
If everything is ok , the password will be updated
*/

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固