Subversion Repository Public Repository

Nextrek

Diff Revisions 415 vs 423 for /Android/SmartCharging/endPoints/nightly/repositories/UserRepository.php

Diff revisions: vs.
  @@ -28,36 +28,42 @@
28 28
29 29 if (!$this->checkUserName($user)) {
30 30 $status["id"] = -1;
31 - $status["return"] = 1;
31 + $status["return"] = 1; //username già registrato
32 + $status["token"] = "";
32 33 return $status;
33 34 }
34 35
35 36 if (!$this->checkEmail($user)) {
36 37 $status["id"] = -1;
37 - $status["return"] = 2;
38 + $status["return"] = 2; //email già registrata
39 + $status["token"] = "";
38 40 return $status;
39 41 }
40 42
41 43 $hashedPwd = password_hash($password, PASSWORD_DEFAULT);
44 + $newToken = sha1($user->username.session_id().time());
42 45
43 - $query = "INSERT INTO utente(username, password, nominativo, cell, email)
46 + $query = "INSERT INTO utente(username, password, nominativo, cell, email, token)
44 47 VALUES ('".$user->username."',
45 48 '".$hashedPwd."',
46 49 '".$user->nominativo."',
47 50 '".$user->cell."',
48 - '".$user->email."')";
51 + '".$user->email."',
52 + '".$newToken."')";
49 53
50 54 //echo "<br/>".$query."<br/>";
51 55
52 56 $this->db->exec($query);
53 57 $status["id"] = $this->db->lastInsertId();
54 58 $status["return"] = 0;
59 + $status["token"] = $newToken;
55 60 return $status;
56 61 //echo "New record created successfully";
57 62 } catch (PDOException $e) {
58 63 echo $e->getMessage();
59 64 $status["id"] = -1;
60 65 $status["return"] = 3;
66 + $status["token"] = "";
61 67 return $status;
62 68 }
63 69
  @@ -72,7 +78,8 @@
72 78 $row = ($result->rowCount()>0) ? $result->fetch() : null;
73 79
74 80 if (!is_null($row) && password_verify($password, $row["password"])) {
75 - $newToken = sha1($row["email"].session_id().time());
81 + //$newToken = sha1($row["email"].session_id().time());
82 + $newToken = sha1($username.session_id().time());
76 83
77 84 $queryToken = "UPDATE utente
78 85 SET token='".$newToken."'