Skip to content
Snippets Groups Projects
Commit ec7fef24 authored by Maxime FRIESS's avatar Maxime FRIESS :blue_heart:
Browse files

Merge branch 'feature/fix-use-email-for-login' into 'develop'

Use email for authentication

See merge request !6
parents 8363d524 801a501d
Branches
Tags
1 merge request!6Use email for authentication
Pipeline #100565 failed with stages
in 46 seconds
......@@ -11,9 +11,10 @@
* @OA\JsonContent(
* required={"username","password"},
* @OA\Property(
* property="username",
* property="email",
* type="string",
* description="Username of the user",
* format="email",
* description="Email of the user",
* ),
* @OA\Property(
* property="password",
......@@ -43,7 +44,7 @@ public function authorize()
public function rules()
{
return [
'username' => 'required|string',
'email' => 'required|string|email',
'password' => 'required|string',
];
}
......
......@@ -25,6 +25,21 @@ public function test_empty() {
$response->assertStatus(422);
}
public function test_invalid_email() {
$user = User::create([
'username' => 'test',
'email' => 'test@localhost',
'password' => Hash::make('test'),
]);
$response = $this->postJson("/api/auth/login", [
"email" => "testfdfgf",
"password" => "123"
]);
$response->assertStatus(422);
}
public function test_wrong_password() {
$user = User::create([
......@@ -34,7 +49,7 @@ public function test_wrong_password() {
]);
$response = $this->postJson("/api/auth/login", [
"username" => "test",
"email" => "test@localhost",
"password" => "123"
]);
$response->assertStatus(401);
......@@ -48,7 +63,7 @@ public function test_good() {
]);
$response = $this->postJson("/api/auth/login", [
"username" => "test",
"email" => "test@localhost",
"password" => "test",
]);
......
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