0
I am developing a system with Laravel and I have the following objective: To make only the admin user can register new users. My problem is not to block the access of ordinary users to the user registration, but to make the user registration accessible with the logged in administrator, Because in the Standard the user registration happens without the user being logged in and when I put a button inside the system directing to the user registration it blocks, redirects to the home. In case my system is all ready, missing only the registration of users be accessible. I hope I have made clear my problem.
Function Register:
public function salvar()
{
$name = request()->input('name');
$email = request()->input('email');
$password = request()->input('password');
$passwords = bcrypt($password);
DB::insert('INSERT INTO users (name, email, password) VALUES (?, ?, ?)', array($name, $email, $passwords));
return redirect() ->action('HomeController@index');
}
I had started to do this, only that as I would have to create another controller pro Register I would have to use the same encryption method of Aravel q is bcrypt, only that I don’t know how to use this encryption method... But thanks for your answer, I will try to understand how bcrypt works.
– João.Mistura
it’s like I said there, you can use the
Hash:make
To encrypt the password, have a look at the documentation. https://laravel.com/docs/5.6/hashing– arllondias
is that I made my registration structure different, I’ll put along with the question, but it worked legal.
– João.Mistura
works not kkk forget
– João.Mistura
Yes, try to do something similar to my answer, I will modify according to what I understand may be your need
– arllondias
now it worked, put $passwords = bcrypt($password); dps passed $passwords in array
– João.Mistura
Good @João.Mistura, I edited my answer, I think you can use that way, not to create a query inside your controller
– arllondias
blzz, @arllondias valeu
– João.Mistura