summaryrefslogtreecommitdiffstats
path: root/models/confirmKey.php
diff options
context:
space:
mode:
authorMichael Francis <edude03@gmail.com>2011-05-28 13:28:16 -0400
committerMichael Francis <edude03@gmail.com>2011-05-28 13:28:16 -0400
commit2389d66da849798f8d4ec5f10e3b07c11da49185 (patch)
treee22556d12982395b469a23420c662662e3e064cc /models/confirmKey.php
downloadotakuhub-2389d66da849798f8d4ec5f10e3b07c11da49185.tar.xz
Initial Commit
Diffstat (limited to 'models/confirmKey.php')
-rw-r--r--models/confirmKey.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/models/confirmKey.php b/models/confirmKey.php
new file mode 100644
index 0000000..6a941ad
--- /dev/null
+++ b/models/confirmKey.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace app\models;
+
+
+use lithium\util\String;
+use lithium\util\Validator;
+
+class confirmKey extends \lithium\data\Model {
+ //Comfirmation Key "salt"
+ public $secret = "marshmellows"; //I don't know why either?
+
+ //To bypass mongo bug
+ protected $_meta = array('key' => '_id');
+ //array('isValidKey', 'message' => 'Key does not exist');
+
+ public static function __init()
+ {
+ //Make sure the class we extend inits.
+ parent::__init();
+
+ //Checks if the key is valid (in the database);
+ Validator::add('isValidKey', function($key) {
+ return confirmKey::count(array('conditions' => compact('key'))) == 1;
+ });
+ }
+
+ //For now, this will remain, but eventually it should just filter the save
+ //Method since the confirmation key doesn't really need to be returned to the controller.
+ public function generate($email)
+ {
+ //Doesn't need to be ultra secure since they just need to click the generated link
+ return String::hash($email.$this->secret, array('type' => 'crc32'));
+ }
+
+ /*
+ * Old Validates function
+ public function isValidKey($key)
+ {
+ //If they key is valid, it should be found in the database
+ //If there is 1 key that matches the input key,
+ return confirmKey::count(array('conditions' => compact('key'))) == 1;
+ }
+ */
+}
+?> \ No newline at end of file