network_id = $network_id; $this->type = $type; $this->user = $user; } /** * Set the data under validation. * * @param array $data * @return $this */ public function setData($data) { $this->data = $data; return $this; } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool * @throws AppException */ public function passes($attribute, $value) { $config = NhNetworksConfig::where('network_id', $this->network_id)->first(); if (isset($config) && $config->password_validation == 'MAX') { $validator = Validator::make($this->data, [ 'password' => 'required|string' ]); if ($validator->fails()) { throw new AppException(trans('validation.required', ['attribute' => 'password']), 422); } if ($this->type == 'agent') { $network_agent_id = $this->data['network_agent_id'] ?? $this->data['issuer_network_agent_id']; $agent = AgentPlus::where('network_agent_id', $network_agent_id)->first(); return checkPassword($value, $agent->encrypted_password, $agent->salt); } else { return checkPassword($value, $this->user->encrypted_password, $this->user->salt); } } return true; } /** * Get the validation error message. * * @return string */ public function message() { return trans('messages.incorrect_user_password'); } }