2017 © Pedro Peláez
 

library reg-and-auth

Simple package for registering, activation, authentication and sending password reminders

image

aerynl/reg-and-auth

Simple package for registering, activation, authentication and sending password reminders

  • Wednesday, July 27, 2016
  • by aerynl
  • Repository
  • 3 Watchers
  • 3 Stars
  • 75 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

reg-and-auth

Simple package for registering, activation, authentication and sending password reminders, (*1)

Installing

  • composer require aerynl/reg-and-auth "dev-master"
  • php artisan vendor:publish --provider="Aerynl\RegAuth\RegAuthServiceProvider"
  • php artisan migrate

2 and 3 will update database fields according to package requirements. It will insert the following fields (if they are not already present): username, activated, activation_code, reset_password_code. Also if activated field is just created, it will set all the current users as activated., (*2)

How to use

Login

by username and password

$result = Aerynl\RegAuth\RegAuth::login($username, $password, $remember);, (*3)

$username and $password are required parameters, $remember is not required., (*4)

This function will check $username and $password for non-emptiness, find user by username or email, check if user is activated and log him in if everything is ok., (*5)

It will return array('success' => false, 'message' => '...') in case of fail and array('success' => true) in case of success., (*6)

by id

$result = Aerynl\RegAuth\RegAuth::simpleLoginById($id);, (*7)

This function will check $id for non-emptiness, find user by id, check if user is activated and log him in if everything is ok., (*8)

It will return array('success' => false, 'message' => '...') in case of fail and array('success' => true) in case of success., (*9)

Get User

$user = Aerynl\RegAuth\RegAuth::getUser();, (*10)

Fetches currently authenticated user, (*11)

Returns null if there is no user in session., (*12)

Logout

Aerynl\RegAuth\RegAuth::logout();, (*13)

Logs out currently authenticated user, (*14)

Register

$result = Aerynl\RegAuth\RegAuth::register($user_data);, (*15)

$user_data is array, which must have email, password and password_confirmation. It also may have another fields, which will be stored to users table., (*16)

This function will do the following: * check $user_data for validity * check if password and password_confirmation match * check if there is no user with the same email or username * register user * generate activation_code, (*17)

It will return array('success' => false, 'message' => '...') in case of fail and array('success' => true, 'user' => $user) in case of success., (*18)

Activate

$result = Aerynl\RegAuth\RegAuth::activate($hash);, (*19)

$hash is a string, containing activation code., (*20)

This function search for not activated user with activation_code = $hash and activates him., (*21)

It will return array('success' => false, 'message' => '...') in case of fail and array('success' => true, 'user' => $user) in case of success., (*22)

Forgot password

$result = Aerynl\RegAuth\RegAuth::generateForgotPassHash($username);, (*23)

This function will check $username for non-emptiness, find user by username or email and generate reset_password_code., (*24)

It will return array('success' => false, 'message' => '...') in case of fail and array('success' => true, 'user' => $user) in case of success., (*25)

Forgot password step 2

$result = Aerynl\RegAuth\RegAuth::processForgotPassHash($hash);, (*26)

This function search for user with reset_password_code = $hash and generates a new password for him., (*27)

It will return array('success' => false, 'message' => '...') in case of fail and array('success' => true, 'user' => $user, 'new_pass' => $new_pass) in case of success., (*28)

Password generator

$pass = Aerynl\RegAuth\RegAuth::generatePass();, (*29)

Generates simple 6-number password, (*30)

Change password

$result = Aerynl\RegAuth\RegAuth::changePass($pass_data, $user_id);, (*31)

$pass_data is array, which must have old_password, new_password and password_confirmation., (*32)

This function search for user with id = $user_id, checks if $pass_data['old_password'] is correct, checks if $pass_data['new_password'] and $pass_data['password_confirmation'] match and saves new password if everything is ok., (*33)

It will return array('success' => false, 'message' => '...') in case of fail and array('success' => true) in case of success., (*34)

The Versions

27/07 2016

5.2.x-dev

5.2.9999999.9999999-dev http://github.com/aerynl/reg-and-auth

Simple package for registering, activation, authentication and sending password reminders

  Sources   Download

MIT

The Requires

 

by Olesya Pavlova

laravel auth

16/03 2016

dev-master

9999999-dev http://github.com/aerynl/reg-and-auth

Simple package for registering, activation, authentication and sending password reminders

  Sources   Download

MIT

The Requires

 

by Olesya Pavlova

laravel auth