Subversion Repository Public Repository

Nextrek

Diff Revisions 517 vs 519 for /Android/SmartCharging/endPoints/nightly/repositories/UserRepository.php

Diff revisions: vs.
  @@ -136,7 +136,7 @@
136 136 }
137 137 }
138 138
139 - public function facebookLogin($fb_user, $user_email, $fb_token) {
139 + public function facebookLogin($fb_user, $user_email, $fb_token, $username = null) {
140 140 $status = array();
141 141
142 142 FacebookSession::setDefaultApplication(
  @@ -171,7 +171,7 @@
171 171 $u_last_name = $graphObject->getProperty('last_name');
172 172 $u_email = $graphObject->getProperty('email');
173 173
174 - $sql = "SELECT id FROM utente WHERE email='".$user_email."'";
174 + $sql = "SELECT id, username FROM utente WHERE email='".$user_email."'";
175 175
176 176 $result = $this->db->query($sql);
177 177 $row = ($result->rowCount()>0) ? $result->fetch() : null;
  @@ -184,14 +184,16 @@
184 184
185 185 $this->db->exec($sql);
186 186 $status["id"] = $row["id"];
187 + $status["username"] = $row["username"];
187 188
188 189 } else { //creazione nuova utenza
189 190
190 - $sql = "INSERT INTO utente (nome,cognome,email,token)
191 - VALUES ('".$u_first_name."','".$u_last_name."','".$u_email."','".$fb_token."')";
191 + $sql = "INSERT INTO utente (nome,cognome,email,token,username)
192 + VALUES ('".$u_first_name."','".$u_last_name."','".$u_email."','".$fb_token."','".$username."')";
192 193
193 194 $this->db->exec($sql);
194 195 $status["id"] = $this->db->lastInsertId();
196 + $status["username"] = $username;
195 197
196 198 }
197 199
  @@ -204,6 +206,7 @@
204 206 $status["return"] = 1;
205 207 $status["id"] = -1;
206 208 $status["token"] = "";
209 + $status["username"] = "";
207 210 return $status;
208 211 }
209 212 }