From d0251553146256bfa03ee63d77fcc90582a1289d Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sat, 8 Nov 2008 01:56:59 +0000 Subject: The start of an authentication module. This provides the installation and a basic install test. There is no interface at the moment to do authentication. It is dependent on the install of the user module. --- modules/auth/helpers/auth_installer.php | 63 +++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 modules/auth/helpers/auth_installer.php (limited to 'modules/auth/helpers/auth_installer.php') diff --git a/modules/auth/helpers/auth_installer.php b/modules/auth/helpers/auth_installer.php new file mode 100644 index 00000000..b1477ff8 --- /dev/null +++ b/modules/auth/helpers/auth_installer.php @@ -0,0 +1,63 @@ +where("name", "auth")->find()->version; + } catch (Exception $e) { + if ($e->getCode() == 44) { + $base_version = 0; + } else { + Kohana::log("error", $e); + throw $e; + } + } + Kohana::log("debug", "base_version: $base_version"); + + if ($base_version == 0) { + $db->query("CREATE TABLE IF NOT EXISTS `passwords` ( + `id` int(9) NOT NULL auto_increment, + `user_id` int(9) NOT NULL, + `password` varchar(1128) NOT NULL, + `logins` int(10) unsigned NOT NULL default '0', + `last_login` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`id`), + UNIQUE KEY (`user_id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + + $user_module = ORM::factory("module")->where("name", "auth")->find(); + $user_module->name = "auth"; + $user_module->version = 1; + $user_module->save(); + + $user = ORM::factory("user")->where("name", "admin")->find(); + Auth::instance()->set_user_password($user->id, "admin"); + } + } + + public static function uninstall() { + $db = Database::instance(); + $db->query("DROP TABLE IF EXISTS `passwords`;"); + $auth_module = ORM::factory("module")->where("name", "auth")->find(); + $auth_module->delete(); + } +} \ No newline at end of file -- cgit v1.2.3