|
@@ -15,7 +15,7 @@ function user_create()
|
15
|
15
|
error(422, "Username too short");
|
16
|
16
|
if (database_exec("SELECT id FROM users WHERE `username` = :username",
|
17
|
17
|
array(":username" => $username))->fetch() !== false)
|
18
|
|
- error(409, "Username already exists");
|
|
18
|
+ error(409, "Username already taken");
|
19
|
19
|
database_exec("INSERT INTO users (`username`, `password`) ".
|
20
|
20
|
"VALUES(:username, :password)", array(":username" => $username,
|
21
|
21
|
":password" => hash_password($password)));
|
|
@@ -37,7 +37,7 @@ function user_login($username = false)
|
37
|
37
|
$args = array(":username" => $username);
|
38
|
38
|
$u = database_exec($query, $args)->fetch();
|
39
|
39
|
if ($u === false)
|
40
|
|
- error(401, "Wrong username or password");
|
|
40
|
+ error(401, "Bad credentials");
|
41
|
41
|
$token = hash_password(uniqid(mt_rand(), true));
|
42
|
42
|
database_exec("INSERT INTO tokens (`token`, `user`) VALUES (:token, :user)",
|
43
|
43
|
array(":token" => $token, ":user" => $u['id']));
|