Commit 5488664f authored by reminec's avatar reminec
Browse files

Fix auth

parent c2186b2c
Pipeline #343047 failed with stage
in 1 minute and 11 seconds
......@@ -38,7 +38,7 @@ security:
realm: "Limaju's Authentication Desk"
json_login:
check_path: /api/authentication_token
username_path: email
username_path: username
password_path: password
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
......
......@@ -100,10 +100,18 @@ class User implements UserInterface
*/
private $password;
/**
* @Groups({"User:login"})
* @Assert\NotBlank(groups={"login"})
* @Assert\Length(max=64, groups={"login"})
* @SerializedName("username")
*/
private $login;
/**
* @Groups({"User:create", "User:edit"})
* @Assert\NotBlank(groups={"register"})
* @Assert\Length(max=1024, groups={"register", "edit"})
* @Assert\NotBlank(groups={"register, login"})
* @Assert\Length(max=1024, groups={"register", "edit", "login"})
* @SerializedName("password")
*/
private $plainPassword;
......@@ -197,6 +205,17 @@ class User implements UserInterface
return $this;
}
public function getLogin(): ?string
{
return $this->login;
}
public function setLogin($login): self
{
$this->login = $login;
return this;
}
public function getPlainPassword(): string
{
return $this->plainPassword;
......
......@@ -21,16 +21,12 @@ class UserRepository extends ServiceEntityRepository implements UserLoaderInterf
}
/**
* {@inheritdoc }
* @inheritdoc
*/
public function loadUserByUsername($usernameOrEmail)
{
return $this->createQuery(
'SELECT u
FROM App\Entity\User u
WHERE u.username = :query
OR u.email = :query'
)
return $this->createQueryBuilder('u')
->where('u.username = :query or u.email = :query')
->setParameter('query', $usernameOrEmail)
->getQuery()
->getOneOrNullResult();
......
......@@ -38,7 +38,7 @@ final class JwtDecorator implements NormalizerInterface
$docs['components']['schemas']['Credentials'] = [
'type' => 'object',
'properties' => [
'email' => [
'username' => [
'type' => 'string',
'example' => 'api',
],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment