I have made until now an app with login/register and it works fine. After the registration a welcome email is sent.
But what i would like to do is to send a link, within that mail, that only after clicking on it, it is possible to login.
Like the common registration email for forum etc..
Someone can help me please?
This is the postRegister method:
public function postRegister()
{
$input = Input::all();
$rules = array(
'username' => 'required',
'password' => 'required');
$validation = Validator::make($input, $rules);
if ($validation->passes()) {
$password = $input['password'];
$password = Hash::make($password);
$user = new User;
$user->username = $input['username'];
$user->email = $input['email'];
$user->password = $password;
$mailer = new Mailers\UserMailer($user);
// var_dump($mailer);
$mailer->welcomeMail()->deliver();
$user->save();
return Redirect::to('afterRegister');
}
return Redirect::back()->withInput()->withErrors($validation)->with('message', 'Validation Errors!');
}
Thank you
First, a route will be needed to display a notice to the user that they should click the email verification link in the verification email that Laravel sent them after registration. Second, a route will be needed to handle requests generated when the user clicks the email verification link in the email.
Here are a few clues (not gonna write the code for you).
confirmation
, confirmed
.registration/verify/{confirmation}
, in which you try and find a user in your DB with the given confirmation code (if found, set user's confirmed
field to 1).str_random()
helper function for this).confirmation
= the random code, confirmed
= 0)Auth attempts can now be done like this:
$user = array(
'username' => Input::get('username'),
'password' => Input::get('password'),
'confirmed' => 1
);
if (Auth::attempt($user)) {
// success!
return Redirect::route('restricted/area');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With