fix: Update phone-input to use frontend IP lookup from ember-core#117
Merged
fix: Update phone-input to use frontend IP lookup from ember-core#117
Conversation
Changes:
- Import lookupUserIp utility from @fleetbase/ember-core
- Replace backend fetch.get('lookup/whois') with frontend lookupUserIp()
- Update error handling and debug messages
This fixes the issue where phone-input was getting server IP location
instead of user IP location. Now uses the new frontend IP lookup utility
that correctly returns the user's actual location.
Benefits:
- Accurate country code detection for phone number formatting
- Faster lookup (1 network hop vs 2)
- No backend dependency
- Consistent with other components using currentUser.whois cache
Depends on: fleetbase/ember-core PR #73 (frontend IP lookup utility)
Changes: - Remove failure callback parameter (not needed) - Always call success() callback, never failure() - Default to 'us' country code if IP lookup fails or returns no country code - Update debug messages to reflect fallback behavior This ensures the phone input always initializes properly even if: - IP lookup API is down - User is behind firewall/VPN that blocks geolocation APIs - API returns incomplete data Better UX: Phone input always works, defaults to US (+1) on any error.
Ember's debug() function doesn't accept multiple parameters like console.log(). Must use string concatenation with + operator instead.
…er-ui into fix/use-frontend-ip-lookup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The phone-input component was using the backend
lookup/whoisendpoint which returns the server's IP location instead of the user's IP location. This caused incorrect country code detection for phone number formatting.Example: User in New York → Server in Frankfurt → Phone input defaults to Germany ❌
Solution
Updated phone-input component to use the new frontend IP lookup utility from ember-core that correctly returns the user's actual location.
Changes
Updated Component
lookupUserIputility from@fleetbase/ember-corefetch.get('lookup/whois')withlookupUserIp()Other Components Verified
The following components use
currentUser.getOption('whois')to read cached whois data and do NOT need updates:These components automatically benefit from the ember-core fix without any changes.
Benefits
✅ Accurate Detection: Gets user's actual country code, not server location
✅ Faster: 1 network hop instead of 2
✅ No Backend Dependency: Direct API call from browser
✅ Consistent: Aligns with other components using whois cache
✅ Better UX: Phone input defaults to correct country
Dependencies
Requires: fleetbase/ember-core PR #73 (Frontend IP lookup utility)
The phone-input component now imports
lookupUserIpfrom ember-core, so ember-core must be updated first.Testing
Manual Testing
Expected Behavior
Migration Notes