Last active
March 26, 2017 00:43
-
-
Save lloy0076/dce62d9b2eddf9a113bfc6d0ae853260 to your computer and use it in GitHub Desktop.
Customer Controller (Backpack)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
// There is a field called 'new_password' which is left EMPTY if the password is not meant to be changed. | |
// WARNING: ONLY do this if you understand the implications of users (probably administrators) knowing | |
// other users' passwords; a more secure suggestion would be to force a password reset! | |
public function update(UpdateRequest $request) | |
{ | |
DB::transaction(function() use ($request, &$redirect_location) { | |
// your additional operations before save here | |
$redirect_location = parent::updateCrud(); | |
// your additional operations after save here | |
// use $this->data['entry'] or $this->crud->entry | |
if ($request->has('new_password') && ! empty($request->input('new_password'))) { | |
// The request validates the length of the password if it exists so we can | |
// assume that it's ok. | |
$this->crud->entry->password = $request->input('new_password'); // this mutates to a hashed password! | |
} | |
$entry = $this->crud->entry; | |
}); | |
return $redirect_location; | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE; I have a mutator that hashes the password so the password is not stored in clear.