Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require "../db.php";
- $data = file_get_contents("php://input");
- $requestBody = json_decode($data, true);
- $login = $requestBody['login'];
- $password = $requestBody['password'];
- $user = R::findOne('users', 'login = ?', array($login));
- if($user)
- {
- if(password_verify($password, $user->password))
- {
- $d = array('access'=>true, 'comment'=>'Auhorization successful!');
- }
- else
- {
- $d = array('access'=>false, 'comment'=>'Incorrect password!');
- }
- }
- else
- {
- $d = array('access'=>false, 'comment'=>'User '.$login.' not found!');
- }
- echo json_encode($d);
- ?>
- {"access":false,"comment":"User not found!"}
- import com.hand.tubes.model.AuthorizationResponse;
- import retrofit2.Call;
- import retrofit2.http.POST;
- import retrofit2.http.Query;
- import retrofit2.http.Headers;
- public interface ApiService {
- @Headers({
- "Content-Type: application/json",
- "Content-Length: 80"
- })
- @POST("auth")
- Call<AuthorizationResponse> authorize(
- @Query("login") String login,
- @Query("password") String password);
- }
- POST http://ru.stackoverflow.com/ HTTP/1.1
- Content-Type: application/x-www-form-urlencoded
- cache-control: no-cache
- Postman-Token: 0db86e7c-1649-41d4-98b9-19aebdbcf18e
- User-Agent: PostmanRuntime/7.3.0
- Accept: */*
- Host: ru.stackoverflow.com
- cookie: prov=e712f6ff-bef2-3787-431c-03d858b78086
- accept-encoding: gzip, deflate
- content-length: 10
- Connection: keep-alive
- test=value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement