Browse Source

fixed error messages

master
Robin Thoni 10 years ago
parent
commit
3948cfb34a
2 changed files with 4 additions and 4 deletions
  1. 2
    2
      status.php
  2. 2
    2
      user.php

+ 2
- 2
status.php View File

8
   $date = new DateTime($token["date"]);
8
   $date = new DateTime($token["date"]);
9
   $date->add(new DateInterval("P1D"));
9
   $date->add(new DateInterval("P1D"));
10
   if ($token === false || $date < new DateTime())
10
   if ($token === false || $date < new DateTime())
11
-    error(401, "Invalid token");
11
+    error(401, "Invalid user token");
12
   return $token["token"];
12
   return $token["token"];
13
 }
13
 }
14
 
14
 
48
   $token = check_token();
48
   $token = check_token();
49
   $status = get_post("status");
49
   $status = get_post("status");
50
   if (strlen($status) < 10)
50
   if (strlen($status) < 10)
51
-    error(422, "Status too short");
51
+    error(422, "Status length too short");
52
 
52
 
53
   $lat = check_float(get_post("latitude", false));
53
   $lat = check_float(get_post("latitude", false));
54
   $long = check_float(get_post("longitude", false));
54
   $long = check_float(get_post("longitude", false));

+ 2
- 2
user.php View File

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

Loading…
Cancel
Save