diff --git a/app/Models/Members/User.php b/app/Models/Members/User.php index 8ba42bb..741d92c 100644 --- a/app/Models/Members/User.php +++ b/app/Models/Members/User.php @@ -30,6 +30,9 @@ class User extends Authenticatable 'password', 'options', 'profile_photo_path', + 'is_active', + 'created_by', + 'updated_by', ]; protected $casts = [ diff --git a/app/Services/EmployeeService.php b/app/Services/EmployeeService.php index 1ab46a8..94f6d7f 100644 --- a/app/Services/EmployeeService.php +++ b/app/Services/EmployeeService.php @@ -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, ]);