Commit b17c06a2334adca962a811e9ba644a1977743bba
1 parent
492296b6f5
Exists in
master
and in
1 other branch
Коммит по системе авторизации работодателя/работника
Showing 3 changed files with 86 additions and 5 deletions Side-by-side Diff
app/Http/Controllers/EmployerController.php
... | ... | @@ -363,14 +363,40 @@ class EmployerController extends Controller |
363 | 363 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); |
364 | 364 | } |
365 | 365 | |
366 | + if (strlen($request->get('password')) < 8) { | |
367 | + return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); | |
368 | + } | |
369 | + | |
370 | + $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?'); | |
371 | + $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', | |
372 | + 'X', 'C', 'V', 'B', 'N', 'M'); | |
373 | + $spec_bool = false; | |
374 | + $alpha_bool = false; | |
375 | + | |
376 | + $haystack = $request->get('password'); | |
377 | + | |
378 | + foreach ($specsumbol as $it) { | |
379 | + if (strpos($haystack, $it) !== false) { | |
380 | + $spec_bool = true; | |
381 | + } | |
382 | + } | |
383 | + | |
384 | + foreach ($alpha as $it) { | |
385 | + if (strpos($haystack, $it) !== false) { | |
386 | + $alpha_bool = true; | |
387 | + } | |
388 | + } | |
389 | + | |
390 | + if ((!$spec_bool) || (!$alpha_bool)) { | |
391 | + return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?")); | |
392 | + } | |
393 | + | |
366 | 394 | if (empty($request->get('surname'))) { |
367 | 395 | $params['surname'] = 'Неизвестно'; |
368 | 396 | } |
369 | - | |
370 | 397 | if (empty($request->get('name_man'))) { |
371 | 398 | $params['name_man'] = 'Неизвестно'; |
372 | 399 | } |
373 | - | |
374 | 400 | $validator = Validator::make($params, $rules, $messages); |
375 | 401 | |
376 | 402 | if ($validator->fails()) { |
... | ... | @@ -378,9 +404,9 @@ class EmployerController extends Controller |
378 | 404 | } else { |
379 | 405 | $user = $this->create($params); |
380 | 406 | event(new Registered($user)); |
381 | - | |
382 | 407 | Auth::guard()->login($user); |
383 | 408 | } |
409 | + | |
384 | 410 | if ($user) { |
385 | 411 | return json_encode(Array("REDIRECT" => redirect()->route('employer.cabinet')->getTargetUrl()));; |
386 | 412 | } else { |
app/Http/Controllers/WorkerController.php
... | ... | @@ -22,6 +22,7 @@ use App\Models\reclame; |
22 | 22 | use App\Models\ResponseWork; |
23 | 23 | use App\Models\sertification; |
24 | 24 | use App\Models\Static_worker; |
25 | +use App\Models\Title_worker; | |
25 | 26 | use App\Models\User; |
26 | 27 | use App\Models\User as User_Model; |
27 | 28 | use App\Models\Worker; |
... | ... | @@ -469,7 +470,7 @@ class WorkerController extends Controller |
469 | 470 | $rules = [ |
470 | 471 | 'surname' => ['required', 'string', 'max:255'], |
471 | 472 | 'name_man' => ['required', 'string', 'max:255'], |
472 | - 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], | |
473 | + 'email' => ['required', 'email', 'max:255', 'unique:users'], | |
473 | 474 | 'password' => ['required', 'string', 'min:8'] |
474 | 475 | ]; |
475 | 476 | |
... | ... | @@ -487,6 +488,10 @@ class WorkerController extends Controller |
487 | 488 | ] |
488 | 489 | ]; |
489 | 490 | |
491 | + if (empty($request->get('email'))) { | |
492 | + return json_encode(Array("ERROR" => "Error: Отсутствует емайл или некорректный емайл")); | |
493 | + } | |
494 | + | |
490 | 495 | if ($request->get('password') !== $request->get('confirmed')){ |
491 | 496 | return json_encode(Array("ERROR" => "Error: Не совпадают пароль и подтверждение пароля")); |
492 | 497 | } |
... | ... | @@ -496,9 +501,12 @@ class WorkerController extends Controller |
496 | 501 | $specsumbol = Array('!','~', '#', '$', '%', '^', '&', '*', '(', ')', '-', '=', ';', ':', '<', '>', '?'); |
497 | 502 | $alpha = Array('Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', |
498 | 503 | 'X', 'C', 'V', 'B', 'N', 'M'); |
504 | + $lenpwd_bool = true; | |
499 | 505 | $spec_bool = false; |
500 | 506 | $alpha_bool = false; |
501 | 507 | |
508 | + if (strlen($haystack) < 8) $lenpwd_bool = false; | |
509 | + | |
502 | 510 | foreach ($specsumbol as $it) { |
503 | 511 | if (strpos($haystack, $it) !== false) { |
504 | 512 | $spec_bool = true; |
... | ... | @@ -511,6 +519,10 @@ class WorkerController extends Controller |
511 | 519 | } |
512 | 520 | } |
513 | 521 | |
522 | + if (!$lenpwd_bool) { | |
523 | + return json_encode(Array("ERROR" => "Error: Недостаточная длина пароля! Увеличьте себе длину пароля!")); | |
524 | + } | |
525 | + | |
514 | 526 | if ((!$spec_bool) || (!$alpha_bool)) { |
515 | 527 | return json_encode(Array("ERROR" => "Error: Нет спецсимволов в пароле, латинские буквы заглавные, а также один из символов: !~#$%^&*()-=;,:<>?")); |
516 | 528 | } |
... | ... | @@ -521,7 +533,7 @@ class WorkerController extends Controller |
521 | 533 | if ($validator->fails()) { |
522 | 534 | return json_encode(array("ERROR" => "Error1: Регистрация оборвалась ошибкой! Не все обязательные поля заполнены. Либо вы уже были зарегистрированы в системе.")); |
523 | 535 | } else { |
524 | - | |
536 | + //dd($params); | |
525 | 537 | $user = $this->create($params); |
526 | 538 | event(new Registered($user)); |
527 | 539 | Auth::guard()->login($user); |
... | ... | @@ -561,10 +573,44 @@ class WorkerController extends Controller |
561 | 573 | return redirect()->route('resume_profile', ['worker' => $request->get('worker_id')])->with('success', 'Ваше сообщение было отправлено!'); |
562 | 574 | } |
563 | 575 | |
576 | + public function TestWorker() | |
577 | + { | |
578 | + $Use = new User(); | |
579 | + | |
580 | + $Code_user = $Use->create([ | |
581 | + 'name' => 'surname name_man', | |
582 | + 'name_man' => 'name_man', | |
583 | + 'surname' => 'surname', | |
584 | + 'surname2' => 'surname2', | |
585 | + 'subscribe_email' => '1', | |
586 | + 'email' => 'email@mail.com', | |
587 | + 'telephone' => '1234567890', | |
588 | + 'password' => Hash::make('password'), | |
589 | + 'pubpassword' => base64_encode('password'), | |
590 | + 'email_verified_at' => Carbon::now(), | |
591 | + 'is_worker' => 1, | |
592 | + ]); | |
593 | + | |
594 | + if ($Code_user->id > 0) { | |
595 | + $Worker = new Worker(); | |
596 | + $Worker->user_id = $Code_user->id; | |
597 | + $Worker->position_work = 1; //'job_titles'; | |
598 | + $Worker->email = 'email@email.com'; | |
599 | + $Worker->telephone = '1234567890'; | |
600 | + $status = $Worker->save(); | |
601 | + | |
602 | + $Title_Worker = new Title_worker(); | |
603 | + $Title_Worker->worker_id = $Worker->id; | |
604 | + $Title_Worker->job_title_id = 1; | |
605 | + $Title_Worker->save(); | |
606 | + } | |
607 | + } | |
608 | + | |
564 | 609 | // Создание пользователя |
565 | 610 | protected function create(array $data) |
566 | 611 | { |
567 | 612 | $Use = new User(); |
613 | + | |
568 | 614 | $Code_user = $Use->create([ |
569 | 615 | 'name' => $data['surname']." ".$data['name_man'], |
570 | 616 | 'name_man' => $data['name_man'], |
... | ... | @@ -578,6 +624,7 @@ class WorkerController extends Controller |
578 | 624 | 'email_verified_at' => Carbon::now(), |
579 | 625 | 'is_worker' => $data['is_worker'], |
580 | 626 | ]); |
627 | + | |
581 | 628 | if ($Code_user->id > 0) { |
582 | 629 | $Worker = new Worker(); |
583 | 630 | $Worker->user_id = $Code_user->id; |
... | ... | @@ -586,6 +633,13 @@ class WorkerController extends Controller |
586 | 633 | $Worker->telephone = $data['telephone']; |
587 | 634 | $Worker->save(); |
588 | 635 | |
636 | + if (isset($Worker->id)) { | |
637 | + $Title_Worker = new Title_worker(); | |
638 | + $Title_Worker->worker_id = $Worker->id; | |
639 | + $Title_Worker->job_title_id = $data['job_titles']; | |
640 | + $Title_Worker->save(); | |
641 | + } | |
642 | + | |
589 | 643 | return $Code_user; |
590 | 644 | } |
591 | 645 | } |
routes/web.php