Only send user data and token on login; Hash dictionary ids

This commit is contained in:
Robbie Antenesse 2019-05-21 11:48:28 -06:00
parent c9f456edfb
commit 59dcdd1694
2 changed files with 5 additions and 9 deletions

View File

@ -71,7 +71,7 @@ VALUES ($new_id, ?, ?, ?, ?)";
if ($results) {
return array_map(function($result) {
return array(
'id' => $result['id'],
'id' => $this->token->hash($result['id']),
'name' => $result['name'] . ' ' . $result['specification'],
);
}, $results);

View File

@ -24,10 +24,10 @@ class User {
}
} else if (password_verify($password, $user['password'])) {
$this->db->execute('UPDATE users SET last_login=' . time() . ' WHERE id=' . $user['id']);
setcookie('token', $this->generateUserToken($user['id'], $user['current_dictionary']));
$token = $this->generateUserToken($user['id'], $user['current_dictionary']);
return array(
'token' => $token,
'user' => $this->getUserData($user['id']),
'dictionary' => $this->token->hash($user['current_dictionary']),
);
}
}
@ -60,14 +60,10 @@ VALUES (?, ?, ?, ?, ?)';
if (isset($new_dictionary['error'])) {
return $new_dictionary;
} else {
setcookie('token', $this->generateUserToken($new_user_id, $new_dictionary));
$token = $this->generateUserToken($new_user_id, $new_dictionary);
return array(
'token' => $token,
'user' => $this->getUserData($new_user_id),
'dictionary' => $this->token->hash($new_dictionary),
'debug' => [
'newUserId' => $new_user_id,
'newDictionary' => $new_dictionary,
],
);
}
}