Commit 8cd8911abf2b4530c5a2fe8f32a9f24d6525da0d

Authored by JLo'w
1 parent 96cf88d2

Connexion enfin fonctionnelle

PremiereActivite/app/src/main/java/com/example/app_10p5/MainActivite.java
@@ -31,7 +31,9 @@ public class MainActivite extends FragmentActivity implements ASyncResponse { @@ -31,7 +31,9 @@ public class MainActivite extends FragmentActivity implements ASyncResponse {
31 31
32 private int mState; 32 private int mState;
33 private String mToken; 33 private String mToken;
  34 + private int mDroit;
34 private long mTimeToken; 35 private long mTimeToken;
  36 + private String mUser;
35 37
36 @Override 38 @Override
37 protected void onCreate(Bundle savedInstanceState){ 39 protected void onCreate(Bundle savedInstanceState){
@@ -174,16 +176,19 @@ public class MainActivite extends FragmentActivity implements ASyncResponse { @@ -174,16 +176,19 @@ public class MainActivite extends FragmentActivity implements ASyncResponse {
174 public void processFinish(JSONObject output) { 176 public void processFinish(JSONObject output) {
175 if(output.length() != 0){ 177 if(output.length() != 0){
176 try{ 178 try{
177 - if(output.get("status").toString() == "ok"){  
178 - mToken = output.get("token").toString(); 179 + if(output.get("status").toString().equals("ok")){
  180 + mToken = output.get("jeton").toString();
179 mTimeToken = System.currentTimeMillis(); 181 mTimeToken = System.currentTimeMillis();
  182 + mDroit = output.getInt("droit");
  183 + mUser = output.get("login").toString();
  184 + Toast.makeText(this, "Bonjour " + mUser + " vous êtes bien connecté pour " + EXPIRATION / (1000 * 60) + " minutes.", Toast.LENGTH_LONG).show();
180 } 185 }
181 else{ 186 else{
182 Toast.makeText(this, "Erreur dans la requête: " + output.get("status"), Toast.LENGTH_LONG).show(); 187 Toast.makeText(this, "Erreur dans la requête: " + output.get("status"), Toast.LENGTH_LONG).show();
183 } 188 }
184 } 189 }
185 catch(Throwable t){ 190 catch(Throwable t){
186 - Toast.makeText(this, "WTF, le cancer est dans l'application!!", Toast.LENGTH_LONG).show(); 191 + Toast.makeText(this, "WTF, le cancer est dans l'application!!" + t.toString(), Toast.LENGTH_LONG).show();
187 } 192 }
188 } 193 }
189 else{ 194 else{