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:
@@ -6,7 +6,6 @@
|
||||
use App\Models\Tenants\TenantUserProfile;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
@@ -100,12 +99,9 @@ public function store(array $data): TenantUserProfile
|
||||
$userId = $this->apiUserId();
|
||||
|
||||
return DB::transaction(function () use ($data, $tenantId, $userId) {
|
||||
// 1. 비밀번호 결정: create_account=false면 NULL (사원 전용, 로그인 불가)
|
||||
$password = null;
|
||||
$createAccount = $data['create_account'] ?? false;
|
||||
if ($createAccount && ! empty($data['password'])) {
|
||||
$password = Hash::make($data['password']);
|
||||
}
|
||||
// 1. 비밀번호 결정: password가 있으면 시스템 계정 생성
|
||||
// User 모델에 'password' => 'hashed' 캐스트가 있으므로 Hash::make() 불필요
|
||||
$password = ! empty($data['password']) ? $data['password'] : null;
|
||||
|
||||
// 2. users 테이블에 사용자 생성
|
||||
$user = User::create([
|
||||
@@ -333,8 +329,9 @@ public function createAccount(int $id, string $password): TenantUserProfile
|
||||
throw new NotFoundHttpException(__('error.not_found'));
|
||||
}
|
||||
|
||||
// User 모델에 'password' => 'hashed' 캐스트가 있으므로 Hash::make() 불필요
|
||||
$profile->user->update([
|
||||
'password' => Hash::make($password),
|
||||
'password' => $password,
|
||||
'must_change_password' => true,
|
||||
'updated_by' => $userId,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user