Guest User

Untitled

a guest
Jan 29th, 2017
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. http://localhost:8080/Extranet/login
  2.  
  3. {
  4. "userName": "Painkiller",
  5. "email": "[email protected]",
  6. "enabled": true
  7. }
  8.  
  9. <?php
  10.  
  11. namespace AppAuthentication;
  12.  
  13. use IlluminateAuthGenericUser;
  14. use IlluminateContractsAuthAuthenticatable;
  15. use IlluminateContractsAuthUserProvider as IlluminateUserProvider;
  16. use GuzzleHttpClient;
  17. use function GuzzleHttpjson_encode;
  18. use function GuzzleHttpjson_decode;
  19. use IlluminateSupportFacadesAuth;
  20. use IlluminateSupportFacadesLog;
  21.  
  22. class UserProvider implements IlluminateUserProvider
  23. {
  24. public function retrieveById($identifier)
  25. {
  26. // TODO: Implement retrieveById() method.
  27. Log::info('retrieveById START');
  28.  
  29. $user = Session::get('loggedUser');
  30.  
  31. //$user = Auth::user();
  32.  
  33. return $user;
  34.  
  35. }
  36.  
  37. public function retrieveByToken($identifier, $token)
  38. {
  39. // TODO: Implement retrieveByToken() method.
  40. Log::info('retrieveByToken START');
  41. }
  42.  
  43. public function updateRememberToken(Authenticatable $user, $token)
  44. {
  45. // TODO: Implement updateRememberToken() method.
  46. Log::info('updateRememberToken START');
  47. }
  48.  
  49. public function retrieveByCredentials(array $credentials) {
  50.  
  51. // TODO: Implement retrieveByCredentials() method.
  52.  
  53. Log::info('retrieveByCredentials START');
  54. Log::info('INSERTED USER CREDENTIAL: '.$credentials['email'] . ' ' .$credentials['password']);
  55.  
  56. $client = new Client(); //GuzzleHttpClient
  57.  
  58. $response = $client->get('http://localhost:8080/Extranet/login',
  59. [
  60. 'auth' => [
  61. 'pswd'
  62. ]
  63. ]);
  64.  
  65. $dettagliLogin = json_decode($response->getBody());
  66.  
  67. Log::info('response: '.(json_encode($dettagliLogin)));
  68.  
  69. //$user = new User('Pippo', '[email protected]', true);
  70.  
  71. $attributes = array(
  72. 'id' => 123,
  73. 'username' => '[email protected]',
  74. 'password' => Hash::make('SuperSecret'),
  75. 'name' => 'Dummy User',
  76. );
  77.  
  78. $user = new GenericUser($attributes);
  79.  
  80. Log::info('USER: '.(json_encode($user)));
  81.  
  82. Session::set('loggedUser', $user);
  83.  
  84. return $user;
  85.  
  86.  
  87. }
  88.  
  89. public function validateCredentials(Authenticatable $user, array $credentials)
  90. {
  91. // TODO: Implement validateCredentials() method.
  92. Log::info('validateCredentials START');
  93. return true;
  94. }
  95.  
  96. }
  97.  
  98. public function retrieveByCredentials(array $credentials) {
  99.  
  100. // TODO: Implement retrieveByCredentials() method.
  101.  
  102. Log::info('retrieveByCredentials START');
  103. Log::info('INSERTED USER CREDENTIAL: '.$credentials['email'] . ' ' .$credentials['password']);
  104.  
  105. $client = new Client(); //GuzzleHttpClient
  106.  
  107. $response = $client->get('http://localhost:8080/Extranet/login',
  108. [
  109. 'auth' => [
  110. 'pswd'
  111. ]
  112. ]);
  113.  
  114. $dettagliLogin = json_decode($response->getBody());
  115.  
  116. Log::info('response: '.(json_encode($dettagliLogin)));
  117.  
  118. //$user = new User('Pippo', '[email protected]', true);
  119.  
  120. $attributes = array(
  121. 'id' => 123,
  122. 'username' => '[email protected]',
  123. 'password' => Hash::make('SuperSecret'),
  124. 'name' => 'Dummy User',
  125. );
  126.  
  127. $user = new GenericUser($attributes);
  128.  
  129. Log::info('USER: '.(json_encode($user)));
  130.  
  131. Session::set('loggedUser', $user);
  132.  
  133. return $user;
  134.  
  135. }
  136.  
  137. Session::set('loggedUser', $user);
  138.  
  139. public function retrieveById($identifier)
  140. {
  141. // TODO: Implement retrieveById() method.
  142. Log::info('retrieveById START');
  143.  
  144. $user = Session::get('loggedUser');
  145.  
  146. //$user = Auth::user();
  147.  
  148. return $user;
  149.  
  150. }
  151.  
  152. Session::set('loggedUser', $user);
  153.  
  154. $user = Session::get('loggedUser');
Advertisement
Add Comment
Please, Sign In to add comment