2017 © Pedro Peláez
 

library laravel-password

Basic tools for updating a user's password on create/update

image

binarycabin/laravel-password

Basic tools for updating a user's password on create/update

  • Friday, November 17, 2017
  • by binarycabin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Laravel-Password

Basic tools for updating a user's password on create/update, (*1)

This package adds a very simple trait to automatically save the user id who created this model., (*2)

Simply add the "\BinaryCabin\LaravelPassword\Traits\HasPassword;" trait to your model:, (*3)

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{

    use \BinaryCabin\LaravelAuthor\Traits\HasAuthorUser;

}

Now when you create a new user: - A temporary password will be generated if it isn't added in the ::create attributes - A password passed in the attributes will automatically be hashed, (*4)

And when calling $user->update: - A password passed in the attributes will automatically be hashed, (*5)

NOTE: Be careful to remove any existing hashing that exists in your application, as this will cause the password to be hashed twice. For example, Laravel's default register controller contains:, (*6)

return User::create([
    'name' => $data['name'],
    'email' => $data['email'],
    'password' => bcrypt($data['password']),
]);

Since the User::create method will now hash the included password, you can update this to:, (*7)

return User::create([
    'name' => $data['name'],
    'email' => $data['email'],
    'password' => $data['password'],
]);

Additionally, the default ResetPasswordController will hash the User's password as well. Add this to the controller to overwrite this functionality:, (*8)

protected function resetPassword($user, $password){
    $user->password = $password;
    $user->setRememberToken(\Illuminate\Support\Str::random(60));
    $user->save();
    event(new \Illuminate\Auth\Events\PasswordReset($user));
    $this->guard()->login($user);
}

The Versions

17/11 2017

dev-master

9999999-dev

Basic tools for updating a user's password on create/update

  Sources   Download

MIT

17/11 2017

1.0.1

1.0.1.0

Basic tools for updating a user's password on create/update

  Sources   Download

MIT

17/11 2017

1.0.0

1.0.0.0

Basic tools for updating a user's password on create/update

  Sources   Download

MIT