Skip to content

Instantly share code, notes, and snippets.

@lloy0076
Last active March 26, 2017 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lloy0076/dce62d9b2eddf9a113bfc6d0ae853260 to your computer and use it in GitHub Desktop.
Save lloy0076/dce62d9b2eddf9a113bfc6d0ae853260 to your computer and use it in GitHub Desktop.
Customer Controller (Backpack)
```
// 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;
}
```
@lloy0076
Copy link
Author

NOTE; I have a mutator that hashes the password so the password is not stored in clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment