API Docs, take 1
This commit is contained in:
parent
44f0139e13
commit
2bb9a17f6a
4 changed files with 104 additions and 9 deletions
19
modules/api.php
Normal file
19
modules/api.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
class api extends CustomModule
|
||||
{
|
||||
public function __default()
|
||||
{
|
||||
// Grabs the user's API key
|
||||
$api_key = false;
|
||||
|
||||
if ($this->uid)
|
||||
{
|
||||
$api_key = $this->redis->hget('user:' . $this->uid, 'api');
|
||||
}
|
||||
|
||||
return array('api_key' => $api_key);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -50,14 +50,6 @@ class user_create extends AnonymousModule
|
|||
// Generates the auth token
|
||||
$auth_token = sha1(microtime());
|
||||
|
||||
// Writes the user data
|
||||
$this->redis->hmset('user:' . $uid, array(
|
||||
'username' => $_POST['username'],
|
||||
'email' => $_POST['email'],
|
||||
'password' => crypt($_POST['password'], '$2y$11$' . String::random(22) . '$'),
|
||||
'auth' => $auth_token,
|
||||
));
|
||||
|
||||
// Creates an API key for the user
|
||||
$api_key = false;
|
||||
|
||||
|
@ -73,6 +65,15 @@ class user_create extends AnonymousModule
|
|||
}
|
||||
}
|
||||
|
||||
// Writes the user data
|
||||
$this->redis->hmset('user:' . $uid, array(
|
||||
'username' => $_POST['username'],
|
||||
'email' => $_POST['email'],
|
||||
'password' => crypt($_POST['password'], '$2y$11$' . String::random(22) . '$'),
|
||||
'auth' => $auth_token,
|
||||
'api' => $api_key,
|
||||
));
|
||||
|
||||
$mapping_fields[] = 'user:api:' . $api_key;
|
||||
|
||||
// Sets the UID mappings
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue