getName() === 'create') { $this->validator->validateLoginInput($data); $customer = Customer::where('email', $data->email)->first(); if (! $customer || ! Hash::check($data->password, $customer->password)) { return (object) [ 'id' => 0, '_id' => 0, 'apiToken' => '', 'token' => '', 'success' => false, 'message' => __('bagistoapi::app.graphql.login.invalid-credentials'), ]; } if ($customer->is_suspended) { return (object) [ 'id' => 0, '_id' => 0, 'apiToken' => '', 'token' => '', 'success' => false, 'message' => __('bagistoapi::app.graphql.login.account-suspended'), ]; } if (empty($customer->api_token)) { $customer->api_token = Str::random(80); $customer->save(); } // Dispatch event to save device_token - PushNotification package will handle this $deviceToken = $data->deviceToken ?? null; if ($deviceToken) { Event::dispatch('bagistoapi.customer.device-token.save', [ 'customerId' => $customer->id, 'deviceToken' => $deviceToken, ]); } // Dispatch customer login event for reward points and other listeners Event::dispatch('customer.after.login', $customer); $token = $customer->createToken('customer-login')->plainTextToken; return (object) [ 'id' => $customer->id, '_id' => $customer->id, 'apiToken' => $customer->api_token, 'token' => $token, 'success' => true, 'message' => __('bagistoapi::app.graphql.login.successful'), ]; //} } return (object) [ 'id' => 0, '_id' => 0, 'apiToken' => '', 'token' => '', 'success' => false, 'message' => __('bagistoapi::app.graphql.login.invalid-request'), ]; } }