Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.86 KB | None | 0 0
  1. [2017-01-16 22:57:51] request.INFO: Matched route "login". {"route":"login","route_parameters":{"_controller":"AppBundle\Controller\SecurityController::loginAction","_route":"login"},"request_uri":"http://localhost:8000/login","method":"GET"} []
  2. [2017-01-16 22:57:51] security.INFO: Populated the TokenStorage with an anonymous Token. [] [][2017-01-16 23:00:46] request.INFO: Matched route "login". {"route":"login","route_parameters":{"_controller":"AppBundle\Controller\SecurityController::loginAction","_route":"login"},"request_uri":"http://localhost:8000/login","method":"POST"} []
  3. [2017-01-16 23:00:46] security.INFO: Authentication request failed. {"exception":"[object] (Symfony\Component\Security\Core\Exception\BadCredentialsException(code: 0): Bad credentials. at /Users/mac/symfony-project/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php:73, Symfony\Component\Security\Core\Exception\UsernameNotFoundException(code: 0): Username "admin" does not exist. at /Users/mac/symfony-project/vendor/symfony/symfony/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php:109)"} []
  4.  
  5. SecurityController.php on line 28:
  6. BadCredentialsException {#100 ▼
  7. -token: UsernamePasswordToken {#99 ▼
  8. -credentials: "abcdef"
  9. -providerKey: "main"
  10. -user: "admin"
  11. -roles: []
  12. -authenticated: false
  13. -attributes: []
  14. }
  15. #message: "Bad credentials."
  16. #code: 0
  17. #file: "../vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthentication ▶"
  18. #line: 73
  19.  
  20. security:
  21. encoders:
  22. AppBundleEntityUser:
  23. algorithm: bcrypt
  24. cost: 12
  25.  
  26. providers:
  27. in_memory:
  28. memory: ~
  29. user_provider:
  30. entity:
  31. class: AppBundleEntityUser
  32. property: username
  33.  
  34. firewalls:
  35. main:
  36. anonymous: ~
  37. form_login:
  38. login_path: login
  39. check_path: login
  40.  
  41. /**
  42. * @Route("/login", name="login")
  43. */
  44. public function loginAction(Request $request)
  45. {
  46. $form = $this->createForm(LoginType::class);
  47.  
  48. $authenticationUtils = $this->get('security.authentication_utils');
  49.  
  50. $a = 1;
  51. $a = 0;
  52.  
  53. if ($a == 1)
  54. $error = $authenticationUtils->getLastAuthenticationError();
  55. else
  56. die(dump($authenticationUtils->getLastAuthenticationError()));
  57.  
  58. $lastUsername = $authenticationUtils->getLastUsername();
  59.  
  60. return $this->render('security/login.html.twig', array(
  61. 'form' => $form->createView(),
  62. 'last_username' => $lastUsername,
  63. 'error' => $error,
  64. ));
  65. }
  66.  
  67. <form action="{{ path('login') }}" method="post">
  68. <label for="username">Username:</label>
  69. <input type="text" id="username" name="_username" />
  70.  
  71. <label for="password">Password:</label>
  72. <input type="password" id="password" name="_password" />
  73.  
  74. <button type="submit">login</button>
  75. </form>
  76.  
  77. <?php
  78.  
  79. namespace AppBundleEntity;
  80.  
  81. use DoctrineORMMapping as ORM;
  82. use SymfonyComponentSecurityCoreUserUserInterface;
  83. use SymfonyBridgeDoctrineValidatorConstraintsUniqueEntity;
  84. use SymfonyComponentValidatorConstraints as Assert;
  85.  
  86. /**
  87. * User
  88. *
  89. * @ORMTable(name="user")
  90. * @ORMEntity(repositoryClass="AppBundleRepositoryUserRepository")
  91. * @UniqueEntity(fields="username", message="Username already taken")
  92. */
  93. class User implements UserInterface
  94. {
  95. /**
  96. * @var int
  97. *
  98. * @ORMColumn(name="id", type="integer")
  99. * @ORMId
  100. * @ORMGeneratedValue(strategy="AUTO")
  101. */
  102. private $id;
  103.  
  104. /**
  105. * @var string
  106. * @AssertNotBlank()
  107. * @ORMColumn(name="username", type="string", length=255, unique=true)
  108. */
  109. private $username;
  110.  
  111. /**
  112. * @var string
  113. *
  114. * @ORMColumn(name="password", type="string", length=255)
  115. */
  116. private $password;
  117.  
  118. /**
  119. * @var DateTime
  120. *
  121. * @ORMColumn(name="created_at", type="datetime")
  122. */
  123. private $createdAt;
  124.  
  125. /**
  126. * @AssertNotBlank()
  127. * @AssertLength(max=255)
  128. */
  129. private $plainPassword;
  130.  
  131. public function __construct()
  132. {
  133. $this->createdAt = new DateTime();
  134. }
  135.  
  136. /**
  137. * Get id
  138. *
  139. * @return int
  140. */
  141. public function getId()
  142. {
  143. return $this->id;
  144. }
  145.  
  146. /**
  147. * Set username
  148. *
  149. * @param string $username
  150. *
  151. * @return User
  152. */
  153. public function setUsername($username)
  154. {
  155. $this->username = $username;
  156.  
  157. return $this;
  158. }
  159.  
  160. /**
  161. * Get username
  162. *
  163. * @return string
  164. */
  165. public function getUsername()
  166. {
  167. return $this->username;
  168. }
  169.  
  170. /**
  171. * Set password
  172. *
  173. * @param string $password
  174. *
  175. * @return User
  176. */
  177. public function setPassword($password)
  178. {
  179. $this->password = $password;
  180.  
  181. return $this;
  182. }
  183.  
  184. /**
  185. * Get password
  186. *
  187. * @return string
  188. */
  189. public function getPassword()
  190. {
  191. return $this->password;
  192. }
  193.  
  194. /**
  195. * Set createdAt
  196. *
  197. * @param DateTime $createdAt
  198. *
  199. * @return User
  200. */
  201. public function setCreatedAt($createdAt)
  202. {
  203. $this->createdAt = $createdAt;
  204.  
  205. return $this;
  206. }
  207.  
  208. /**
  209. * Get createdAt
  210. *
  211. * @return DateTime
  212. */
  213. public function getCreatedAt()
  214. {
  215. return $this->createdAt;
  216. }
  217.  
  218. /**
  219. * Get plain password
  220. *
  221. * @return string
  222. */
  223. public function getPlainPassword()
  224. {
  225. return $this->plainPassword;
  226. }
  227.  
  228. /**
  229. * Set plain password
  230. *
  231. * @param string $password
  232. *
  233. * @return Users
  234. */
  235. public function setPlainPassword($password)
  236. {
  237. $this->plainPassword = $password;
  238.  
  239. return $this;
  240. }
  241.  
  242. public function getRoles()
  243. {
  244. return array('ROLE_USER');
  245. }
  246.  
  247. public function eraseCredentials()
  248. {
  249. }
  250.  
  251. public function getSalt()
  252. {
  253. }
  254. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement