From b4be22197da7bd3c3887f70fffa422d8b6885a3f Mon Sep 17 00:00:00 2001 From: Oreolek Date: Sat, 29 Dec 2012 20:28:11 +0700 Subject: [PATCH] registration --- application/classes/Controller/Register.php | 22 +++++++++++++++++++++ application/views/register.php | 15 ++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 application/classes/Controller/Register.php create mode 100644 application/views/register.php diff --git a/application/classes/Controller/Register.php b/application/classes/Controller/Register.php new file mode 100644 index 0000000..535be93 --- /dev/null +++ b/application/classes/Controller/Register.php @@ -0,0 +1,22 @@ +logged_in()) return $this->request->redirect(''); + if ($_POST){ + $data = arr::extract($_POST, array('username', 'password', 'email', 'password_confirm')); + $user = ORM::factory('user')->values($data); + if ($user->check()){ + $user->create(); + $login_role = new Model_Role(array('name' =>'login')); + $author_role = new Model_Role(array('name' =>'author')); + $user->add('roles',$login_role); + $user->add('roles',$author_role); + Auth::instance()->login($data['login'], $data['password']); + $this->request->redirect(''); + } + else $this->template->error = $post->errors('register');//"Ошибка валидации."; + } + } +} diff --git a/application/views/register.php b/application/views/register.php new file mode 100644 index 0000000..9eb3d97 --- /dev/null +++ b/application/views/register.php @@ -0,0 +1,15 @@ +post('title',"Регистрация")->post('styles','main.css')->execute() ?> + +
+
+

Введите логин, пароль и e-mail.

+ +

+

+

+

+

+

+ + +execute() ?>