mirror of
https://gitlab.com/omair-personal/exchange.git
synced 2026-08-19 04:24:08 +00:00
Check marking before create user
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Role;
|
||||
use App\Marking;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
@@ -58,6 +59,11 @@ class RegisterController extends Controller
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
$marking = Marking::Where('email',$data['email'])->first();
|
||||
if($marking->marking = $data['marking']){
|
||||
redirect('/');
|
||||
}
|
||||
|
||||
$role = Role::where('name','=','member')->first();
|
||||
$user = new User();
|
||||
$user->name = $data['name'];
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Marking::class, function (Faker $faker) {
|
||||
return [
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'marking' => str_random(10)
|
||||
];
|
||||
});
|
||||
@@ -3,17 +3,31 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Marking;
|
||||
use Artisan;
|
||||
|
||||
class RegisterTest extends TestCase
|
||||
{
|
||||
protected $marking;
|
||||
|
||||
public function setUp(){
|
||||
parent::setUp();
|
||||
Artisan::call('db:seed');
|
||||
|
||||
$this->marking = factory(Marking::class)->create();
|
||||
}
|
||||
|
||||
|
||||
/** @test */
|
||||
public function can_register()
|
||||
{
|
||||
$response =
|
||||
$this->postJson('/api/register', [
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@test.app',
|
||||
'email' => $this->marking->email,
|
||||
'password' => 'secret',
|
||||
'password_confirmation' => 'secret',
|
||||
'marking' => $this->marking->marking
|
||||
])
|
||||
->assertSuccessful()
|
||||
->assertJsonStructure(['id', 'name', 'email']);
|
||||
|
||||
Reference in New Issue
Block a user