2017 © Pedro Peláez
 

library bandrek

Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.

image

nuwira/bandrek

Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.

  • Tuesday, March 6, 2018
  • by matriphe
  • Repository
  • 8 Watchers
  • 1 Stars
  • 132 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 9 Versions
  • 57 % Grown

The README.md

Bandrek

Build Status Total Download Latest Stable Version, (*1)

Bandrek is local word in Javanese that means a lock pick. We use lock pick to open a padlock if the key is lost., (*2)

Bandrek replaces Laravel's password recovery manager to provide code and token when requesting password recovery. This code can be used as token replacement if you are using REST-API to reset password without visiting web interface., (*3)

Bandrek generate 6 random numeric character as code. Bandrek is also creating 64 characters token that can be used in normal web page interface., (*4)

The scenario is when user request password recovery via REST-API, the user can send the credentials (e-mail and password) and the easy readable code to reset the password., (*5)

Installation

Bandrek only supports Laravel 5.4 and above. To install using Composer, just run this command below., (*6)

composer require nuwira/bandrek

Configuration

Config File

After installed, open config/app.php and find this line., (*7)

Illuminate\Auth\Passwords\PasswordResetServiceProvider::class

Comment or remove it and add that line to override Laravel's password reset handling., (*8)

Nuwira\Bandrek\BandrekServiceProvider::class

Add Facade

This is optional. To add Facade, add config/app.php in the aliases section., (*9)

'Bandrek' => Nuwira\Bandrek\BandrekFacade::class,

If Facade is loaded, you can call these functions, (*10)

Bandrek::getRandomCode($length = 6, $toString = true);
Bandrek::generateToken();
Bandrek::getTokenFromCode($code);
Bandrek::getCodeFromToken($token, $toString = true);

Model File

To be able to send reset password instruction e-mail, open app/User.php (the user model file) and find this line., (*11)

use Illuminate\Foundation\Auth\User as Authenticatable;

Replace that line with this., (*12)

use Nuwira\Bandrek\Auth\User as Authenticatable;

Using Custom Notification

Bandrek by default is using e-mail for notification. You can add or replace using your preferred method by extending abstract class Nuwira\Bandrek\Notification\BandrekNotification. The token and code are available in $this->code and $this->token in the notification class., (*13)

For example, if you want to send the code using Gammu SMS notification, just install and configure it., (*14)

To use SMS and e-mail for code sending, add function in your model that extends Nuwira\Bandrek\Auth\User and inject the notification., (*15)

Notification File: App\Notifications\ResetPassword.php, (*16)

namespace App\Notifications;

use Nuwira\Bandrek\Notification\BandrekNotification;
use Illuminate\Notifications\Messages\MailMessage;
use NotificationChannels\Gammu\GammuChannel;
use NotificationChannels\Gammu\GammuMessage;

class ResetPassword extends BandrekNotification
{
    public function via($notifiable)
    {
        return ['mail', GammuChannel::class];
    }

    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->line('You are receiving this email because we received a password reset request for your account.')
            ->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
            ->line('If you did not request a password reset, no further action is required.');
    }

    public function toGammu($notifiable)
    {
        return (new GammuMessage())
            ->to($phoneNumber)
            ->content('To reset password, use this code: '.$this->code);
    }
}

Model File: App\User.php, (*17)

namespace App;

use Nuwira\Bandrek\Auth\User as BaseUser;
use App\Notifications\ResetPassword as ResetPasswordNotification;

class User extends BaseUser
{
    public function sendPasswordResetNotification($token)
    {
        $this->notify(new ResetPasswordNotification($token));
    }
}

License

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

The Versions

06/03 2018

dev-master

9999999-dev

Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel password nuwira bandrek

06/03 2018

1.1.1

1.1.1.0

Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel password nuwira bandrek

02/03 2018

1.1.0

1.1.0.0

Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel password nuwira bandrek

19/12 2017

1.0.5

1.0.5.0

Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel password nuwira bandrek

11/12 2017

1.0.4

1.0.4.0

Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel password nuwira bandrek

01/09 2017

1.0.3

1.0.3.0

Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel password nuwira bandrek

16/08 2017

1.0.2

1.0.2.0

Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel password nuwira bandrek

29/07 2017

1.0.1

1.0.1.0

Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.

  Sources   Download

MIT

The Requires

 

The Development Requires

29/07 2017

1.0.0

1.0.0.0

Bandrek is password recovery token generation using number as code for Laravel 5.4.x based.

  Sources   Download

MIT

The Requires

 

The Development Requires