summaryrefslogtreecommitdiff
path: root/modules/rest/helpers/rest.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-01-20 00:07:03 -0800
committerBharat Mediratta <bharat@menalto.com>2010-01-20 00:07:03 -0800
commit5119d58e7ff06e1ba922d73bf47aefd242dc888f (patch)
tree2b201427f30083edcd3df88014a48feb16caf5dd /modules/rest/helpers/rest.php
parent66fbbab9071e73df01b316bb29842fdc3b29c39c (diff)
Move access key creation into a helper function.
Diffstat (limited to 'modules/rest/helpers/rest.php')
-rw-r--r--modules/rest/helpers/rest.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php
index fccb365e..cd3de725 100644
--- a/modules/rest/helpers/rest.php
+++ b/modules/rest/helpers/rest.php
@@ -49,6 +49,20 @@ class rest_Core {
identity::set_active_user($user);
}
+ static function get_access_token($user_id) {
+ $key = ORM::factory("user_access_token")
+ ->where("user_id", "=", $user_id)
+ ->find();
+
+ if (!$key->loaded()) {
+ $key->user_id = $user_id;
+ $key->access_key = md5(rand());
+ $key->save();
+ }
+ return $key;
+ }
+
+
/**
* Convert a REST url into an object.
* Eg: "http://example.com/gallery3/index.php/rest/gallery/Family/Wedding" -> Item_Model