You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.
public function postInvite()
{
// Declare the rules for the form validation
$rules = array(
'first_name' => 'required|min:3',
'email' => 'required|email|unique:users',
'password' => 'required|between:3,32',
);
// Create a new validator instance from our validation rules
$validator = Validator::make(Input::all(), $rules);
// If validation fails, we'll exit the operation now.
if ($validator->fails())
{
// Ooops.. something went wrong
return Redirect::back()->withInput()->withErrors($validator);
}
try
{
// Register the user
$user = Sentry::register(array(
'username' => Input::get('first_name'),
'first_name' => Input::get('first_name'),
'email' => Input::get('email'),
'password' => Input::get('password'),
));
// Data to be used on the email view
$data = array(
'user' => $user,
'activationUrl' => URL::route('activate', $user->getActivationCode()),
);
// Send the activation code through email
Mail::send('emails.auth.invite', $data, function($m) use ($user)
{
$m->from('testingmail@gmail.com','test');
$m->to($user->email, $user->first_name . ' ' . $user->last_name);
$m->subject('Hello' . $user->first_name);
});
// Redirect to the register page
return Redirect::back()->with('success','Activation mail was sent!');
}
catch (Cartalyst\Sentry\Users\UserExistsException $e)
{
$this->messageBag->add('email','Something went wrong!');
}
// Ooops.. something went wrong
return Redirect::back()->withInput()->withErrors($this->messageBag);
}
userController@getActivate
public function getActivate($activationCode = null)
{
// Is the user logged in?
if (Sentry::check())
{
return Redirect::to('projects');
}
try
{
// Get the user we are trying to activate
$user = Sentry::getUserProvider()->findByActivationCode($activationCode);
// Try to activate this user account
if ($user->attemptActivation($activationCode))
{
// Redirect to the login page
return Redirect::to('user/login')->with('success', 'Your profile is activated. Now you can log in!');
}
// The activation failed.
$error = 'Something went wrong!';
}
catch (Cartalyst\Sentry\Users\UserNotFoundException $e)
{
$error = $e;
}
// Ooops.. something went wrong
return Redirect::to('user/login')->with('error', $error);
}
The text was updated successfully, but these errors were encountered:
Hi,
I needed invitation system that will send activation email to user, after user visits the link his profile will be activated.
I thought I should share my code if someone will found it useful.
Blade:
UserController@postInvite
userController@getActivate
The text was updated successfully, but these errors were encountered: