Advertisement
Guest User

Untitled

a guest
Oct 6th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <?php
  2. require "../db.php";
  3.  
  4. $data = file_get_contents("php://input");
  5. $requestBody = json_decode($data, true);
  6. $login = $requestBody['login'];
  7. $password = $requestBody['password'];
  8.  
  9. $user = R::findOne('users', 'login = ?', array($login));
  10. if($user)
  11. {
  12. if(password_verify($password, $user->password))
  13. {
  14. $d = array('access'=>true, 'comment'=>'Auhorization successful!');
  15. }
  16. else
  17. {
  18. $d = array('access'=>false, 'comment'=>'Incorrect password!');
  19. }
  20. }
  21. else
  22. {
  23. $d = array('access'=>false, 'comment'=>'User '.$login.' not found!');
  24. }
  25. echo json_encode($d);
  26. ?>
  27.  
  28. {"access":false,"comment":"User not found!"}
  29.  
  30. import com.hand.tubes.model.AuthorizationResponse;
  31.  
  32. import retrofit2.Call;
  33. import retrofit2.http.POST;
  34. import retrofit2.http.Query;
  35. import retrofit2.http.Headers;
  36.  
  37. public interface ApiService {
  38. @Headers({
  39. "Content-Type: application/json",
  40. "Content-Length: 80"
  41. })
  42. @POST("auth")
  43. Call<AuthorizationResponse> authorize(
  44. @Query("login") String login,
  45. @Query("password") String password);
  46. }
  47.  
  48. POST http://ru.stackoverflow.com/ HTTP/1.1
  49. Content-Type: application/x-www-form-urlencoded
  50. cache-control: no-cache
  51. Postman-Token: 0db86e7c-1649-41d4-98b9-19aebdbcf18e
  52. User-Agent: PostmanRuntime/7.3.0
  53. Accept: */*
  54. Host: ru.stackoverflow.com
  55. cookie: prov=e712f6ff-bef2-3787-431c-03d858b78086
  56. accept-encoding: gzip, deflate
  57. content-length: 10
  58. Connection: keep-alive
  59.  
  60. test=value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement