fix(API): 직원 등록 서버 에러 수정
- User 모델 $fillable에 is_active, created_by, updated_by 추가 - EmployeeService 이중 비밀번호 해싱 제거 (모델 hashed 캐스트 활용) - create_account 플래그 의존성 제거 (password 있으면 계정 생성) Fixes: employee-register E2E test failure Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,9 @@ class User extends Authenticatable
|
|||||||
'password',
|
'password',
|
||||||
'options',
|
'options',
|
||||||
'profile_photo_path',
|
'profile_photo_path',
|
||||||
|
'is_active',
|
||||||
|
'created_by',
|
||||||
|
'updated_by',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
use App\Models\Tenants\TenantUserProfile;
|
use App\Models\Tenants\TenantUserProfile;
|
||||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Hash;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
@@ -100,12 +99,9 @@ public function store(array $data): TenantUserProfile
|
|||||||
$userId = $this->apiUserId();
|
$userId = $this->apiUserId();
|
||||||
|
|
||||||
return DB::transaction(function () use ($data, $tenantId, $userId) {
|
return DB::transaction(function () use ($data, $tenantId, $userId) {
|
||||||
// 1. 비밀번호 결정: create_account=false면 NULL (사원 전용, 로그인 불가)
|
// 1. 비밀번호 결정: password가 있으면 시스템 계정 생성
|
||||||
$password = null;
|
// User 모델에 'password' => 'hashed' 캐스트가 있으므로 Hash::make() 불필요
|
||||||
$createAccount = $data['create_account'] ?? false;
|
$password = ! empty($data['password']) ? $data['password'] : null;
|
||||||
if ($createAccount && ! empty($data['password'])) {
|
|
||||||
$password = Hash::make($data['password']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. users 테이블에 사용자 생성
|
// 2. users 테이블에 사용자 생성
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
@@ -333,8 +329,9 @@ public function createAccount(int $id, string $password): TenantUserProfile
|
|||||||
throw new NotFoundHttpException(__('error.not_found'));
|
throw new NotFoundHttpException(__('error.not_found'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// User 모델에 'password' => 'hashed' 캐스트가 있으므로 Hash::make() 불필요
|
||||||
$profile->user->update([
|
$profile->user->update([
|
||||||
'password' => Hash::make($password),
|
'password' => $password,
|
||||||
'must_change_password' => true,
|
'must_change_password' => true,
|
||||||
'updated_by' => $userId,
|
'updated_by' => $userId,
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user