public function createAlumno(array $post) { //var_dump($post); //Sanitisar los valores enviados por el usuario ( POST ) $username = filter_var($post['username_input_data'], FILTER_SANITIZE_STRING); $mail = filter_var($post['email_input_data'], FILTER_SANITIZE_EMAIL); $password = filter_var($post['password_input_data'], FILTER_SANITIZE_STRING); $username = strip_tags($username); $mail = strip_tags($mail); $password = strip_tags($password); //Validar el email $mail = filter_var($mail, FILTER_VALIDATE_EMAIL); $longitudPass = strlen($password); $perfil = Perfil::where('email', '=', $mail)->get(); //Verificar que el email sea valido if (!$mail) { $this->app->redirect($this->app->urlFor('join') . '?attempt=1'); } //Verificar la longitud del password if ($longitudPass < 8) { $this->app->redirect($this->app->urlFor('join') . '?attempt=2'); } //Verificar que el email no exista en la base de datos (Perfil) if (count($perfil) > 0) { $this->app->redirect($this->app->urlFor('join') . '?attempt=3'); } //Verificar que el username no exista en la base de datos $perfil = Perfil::where('username', '=', $username)->get(); if (count($perfil) > 0) { $this->app->redirect($this->app->urlFor('join') . '?attempt=4'); } $user = Authentication::createUser($username, $mail, $password, 4); if ($user) { if (isset($_SESSION['proceso']) && ($_SESSION['proceso']['proceso'] = 1)) { $this->app->redirect('/suscribirme/' . $_SESSION['proceso']['curso']); } else { $this->app->redirect('/' . $username); } } else { $this->app->redirect($this->app->urlFor('join') . '?attempt=5'); } }
} if (!preg_match("#[a-z]+#", $password)) { $error .= "Password must include at least one letter!<br />"; } if (!preg_match("#[A-Z]+#", $password)) { $error .= "Password must include at least one CAPS!<br />"; } //if( !preg_match("#\W+#", $password) ) { // $error .= "Password must include at least one symbol!<br />"; //} if (!empty($error)) { $app->flash('error', $error); $app->redirect('/create/new/user'); } $auth = new Authentication($email, $password); if (!$auth->createUser($first_name, $last_name, $company, $phone, $group)) { $app->flash('error', $error . "<br />" . $auth->getError()); $app->redirect('/create/new/user'); } $_SESSION['user'] = $email; $app->redirect('/'); }); $app->get("/forgotpassword", function () use($app) { $flash = $app->view()->getData('flash'); $error = ""; echo "error: " . $flash['error']; if (isset($flash['error'])) { $error = $flash['error']; } $app->render("Authentication/Forgotpassword.php", array('error' => $error)); });