/**
  * Register the user and start a session
  */
 public function register()
 {
     $fullName = Input::get('fullName');
     $email = Input::get('email');
     $password = Input::get('password');
     // lets validate the users input
     $validator = Validator::make(array('fullName' => $fullName, 'email' => $email, 'password' => $password), array('fullName' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required|min:8'));
     // Commented out for open beta and beyond
     /************* Make sure the email being used has been invited to beta
              *
     		if ( !DB::table('beta')->whereEmail($email)->whereStatus(1)->get() ) {
     			$validator->getMessageBag()->add('used', 'The email used has not been invited.');
     			return Redirect::back()->withErrors($validator)->withInput();
     		}
              *
              ******************/
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $user = new User();
     $user->full_name = $fullName;
     $user->email = $email;
     $user->password = Hash::make($password);
     $user->save();
     if (Auth::attempt(array('email' => $email, 'password' => $password))) {
         sendWelcomeMail();
         return Redirect::to('hud');
     }
     return Redirect::back()->withErrors($validator);
 }
Example #2
0
    Route::resource('credentials', 'CredentialsController', array('only' => array('create', 'destroy')));
    Route::resource('tasks', 'TasksController');
    Route::get('hud', 'HomeController@index');
    Route::get('search', 'HomeController@search');
    Route::get('profile', 'UsersController@index');
});
//----------------- API routes
Route::get('/api/{key}/authId', 'ApiController@authId');
Route::get('/api/{key}/{id}/tasks', 'ApiController@tasks');
Route::get('/api/{key}/{id}/tasks/incomplete', 'ApiController@incompleteTasks');
Route::get('/api/{key}/{id}/tasks/complete', 'ApiController@complete');
//----------------- Admin routes
Route::group(array('before' => 'admin'), function () {
    Route::get('invite', 'AdminController@invite');
});
//-----------------
//-----------------
//-----------------
//----------------- TEST routes
Route::group(array('before' => 'admin'), function () {
    // Send test emails
    Route::get('/testEmails', function () {
        sendBetaFollowUpMail('*****@*****.**');
        sendBetaInviteEmail('*****@*****.**');
        sendWelcomeMail();
        return "All test emails sent";
    });
    Route::get('pivot', function () {
        return Project::find(1)->users;
    });
});
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    // Additional headers
    $headers .= 'From: case.shareup@gmail.com' . "\r\n" . 'Reply-To: case.shareup@gmail.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    mail($to, $subject, $message, $headers);
}
if (isset($body)) {
    $json = json_decode($body);
    $pw = generateRandomString(6);
    if (existsStudent($json->email)) {
        $message = array('error' => 'Student already exists');
    } else {
        if (createStudent($json->name, $pw, $json->birthdate, $json->university, $json->email, $json->cellphone, $json->cv, $json->linkedin)) {
            $student = studentIdByEmail($json->email);
            $studentID = $student['id'];
            $message = array('success' => 'Student was successfully created', 'userid' => $studentID);
            sendWelcomeMail($json->email, $pw);
            if (isset($json->hasPicture)) {
                $message = array('success' => 'Student was successfully created and id will be set', 'userid' => $studentID);
                $_SESSION['id'] = $studentID;
                $_SESSION['email'] = $json->email;
                $_SESSION['type'] = "student";
                $_SESSION['burner'] = "";
            }
        } else {
            $message = array('error' => 'Student was not created');
        }
    }
} else {
    $message = array('error' => 'Inexistent request');
}
$JSONresponse = json_encode($message);