Skip to content

Commit

Permalink
Merge pull request #50 from DearMyPeace/dev/login-issue-mobile-web/#49
Browse files Browse the repository at this point in the history
fix: login issue mobile web/#49
  • Loading branch information
bentraxgel authored Jul 2, 2024
2 parents ada123e + 09390ff commit eb0a608
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 86 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ ios-open:
asset:
npx react-native-asset

cc:
npx react-native start --reset-cache

clean:
rm -rf ./node_modules
rm -rf ./ios/Pods
Expand Down
11 changes: 11 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,16 @@ module.exports = {
: ['@babel/plugin-transform-private-methods', { loose: true }],
moduleResolver,
'react-native-reanimated/plugin',
[
'module:react-native-dotenv',
{
moduleName: '@env',
path: '.env',
blacklist: null,
whitelist: null,
safe: true,
allowUndefined: true,
},
],
],
};
12 changes: 12 additions & 0 deletions ios/dearmypeace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
5F2975D4800947B5B438A508 /* FontAwesome.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A7D7DEC49252466C8666BA0C /* FontAwesome.ttf */; };
641965F627514DDBAF620056 /* Feather.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D5B1D94BBD1045779ABCC8F1 /* Feather.ttf */; };
64880C4F2C3283F9009E2304 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 64880C4E2C3283F8009E2304 /* GoogleService-Info.plist */; };
64880C532C33C1BC009E2304 /* Kalam-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 64880C502C33C1BC009E2304 /* Kalam-Bold.ttf */; };
64880C542C33C1BC009E2304 /* Kalam-Light.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 64880C512C33C1BC009E2304 /* Kalam-Light.ttf */; };
64880C552C33C1BC009E2304 /* Kalam-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 64880C522C33C1BC009E2304 /* Kalam-Regular.ttf */; };
6C81110E134B4133B7BBFA58 /* AntDesign.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 391B37A4C9314BE58D0CA0BD /* AntDesign.ttf */; };
7C21F5F2D9E94F29BCDD103E /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A473DD0784EE4C70A9866D67 /* Ionicons.ttf */; };
7C48246F68C84F3CB383029D /* Foundation.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 76C538F261A64E7A9AFA721A /* Foundation.ttf */; };
Expand Down Expand Up @@ -67,6 +70,9 @@
4AB4F72C4C2246A690E9A574 /* Fontisto.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Fontisto.ttf; path = ../src/assets/fonts/Fontisto.ttf; sourceTree = "<group>"; };
582A185F068242EA99AC1C92 /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialCommunityIcons.ttf; path = ../src/assets/fonts/MaterialCommunityIcons.ttf; sourceTree = "<group>"; };
64880C4E2C3283F8009E2304 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../key/GoogleService-Info.plist"; sourceTree = "<group>"; };
64880C502C33C1BC009E2304 /* Kalam-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "Kalam-Bold.ttf"; path = "../src/assets/fonts/Kalam-Bold.ttf"; sourceTree = "<group>"; };
64880C512C33C1BC009E2304 /* Kalam-Light.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "Kalam-Light.ttf"; path = "../src/assets/fonts/Kalam-Light.ttf"; sourceTree = "<group>"; };
64880C522C33C1BC009E2304 /* Kalam-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "Kalam-Regular.ttf"; path = "../src/assets/fonts/Kalam-Regular.ttf"; sourceTree = "<group>"; };
64C8F1AC2C2BFBBD00CAC7F8 /* dearmypeace.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = dearmypeace.entitlements; path = dearmypeace/dearmypeace.entitlements; sourceTree = "<group>"; };
69C39DA37EE04490A92B2DD3 /* GowunBatang-Regular.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "GowunBatang-Regular.ttf"; path = "../src/assets/fonts/GowunBatang-Regular.ttf"; sourceTree = "<group>"; };
6DF4937B063240499BE351DD /* FontAwesome5_Brands.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome5_Brands.ttf; path = ../src/assets/fonts/FontAwesome5_Brands.ttf; sourceTree = "<group>"; };
Expand Down Expand Up @@ -169,6 +175,9 @@
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
64880C502C33C1BC009E2304 /* Kalam-Bold.ttf */,
64880C512C33C1BC009E2304 /* Kalam-Light.ttf */,
64880C522C33C1BC009E2304 /* Kalam-Regular.ttf */,
13B07FAE1A68108700A75B9A /* dearmypeace */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
00E356EF1AD99517003FC87E /* dearmypeaceTests */,
Expand Down Expand Up @@ -324,6 +333,9 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
64880C532C33C1BC009E2304 /* Kalam-Bold.ttf in Resources */,
64880C542C33C1BC009E2304 /* Kalam-Light.ttf in Resources */,
64880C552C33C1BC009E2304 /* Kalam-Regular.ttf in Resources */,
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
64880C4F2C3283F9009E2304 /* GoogleService-Info.plist in Resources */,
Expand Down
167 changes: 94 additions & 73 deletions ios/dearmypeace/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,99 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>dearmypeace</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string/>
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
<string>Entypo.ttf</string>
<string>EvilIcons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
<string>FontAwesome5_Brands.ttf</string>
<string>FontAwesome5_Regular.ttf</string>
<string>FontAwesome5_Solid.ttf</string>
<string>Foundation.ttf</string>
<string>Ionicons.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>MaterialIcons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Octicons.ttf</string>
<string>Zocial.ttf</string>
<string>Fontisto.ttf</string>
<string>GowunBatang-Bold.ttf</string>
<string>GowunBatang-Regular.ttf</string>
<string>Inder-Regular.ttf</string>
<string>FontAwesome6_Brands.ttf</string>
<string>FontAwesome6_Regular.ttf</string>
<string>FontAwesome6_Solid.ttf</string>
<string>Kalam-Bold.ttf</string>
<string>Kalam-Light.ttf</string>
<string>Kalam-Regular.ttf</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>dearmypeace</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.gt.apps.secretKEY</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>dear-my-peace.site</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
<string>Entypo.ttf</string>
<string>EvilIcons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
<string>FontAwesome5_Brands.ttf</string>
<string>FontAwesome5_Regular.ttf</string>
<string>FontAwesome5_Solid.ttf</string>
<string>Foundation.ttf</string>
<string>Ionicons.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>MaterialIcons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Octicons.ttf</string>
<string>Zocial.ttf</string>
<string>Fontisto.ttf</string>
<string>GowunBatang-Bold.ttf</string>
<string>GowunBatang-Regular.ttf</string>
<string>Inder-Regular.ttf</string>
<string>FontAwesome6_Brands.ttf</string>
<string>FontAwesome6_Regular.ttf</string>
<string>FontAwesome6_Solid.ttf</string>
<string>Kalam-Bold.ttf</string>
<string>Kalam-Light.ttf</string>
<string>Kalam-Regular.ttf</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"react-native-chart-kit": "^6.12.0",
"react-native-collapsible": "^1.6.1",
"react-native-date-picker": "^5.0.4",
"react-native-dotenv": "^3.4.11",
"react-native-element-dropdown": "^2.12.1",
"react-native-encrypted-storage": "^4.0.3",
"react-native-gesture-handler": "^2.16.2",
Expand Down
10 changes: 8 additions & 2 deletions src/hooks/login/useSendUserToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface AppleData {
}

interface GoogleTokenData {
token: string;
access_token: string;
}

const useSendUserToken = (loginType: 'google' | 'apple') => {
Expand All @@ -21,7 +21,13 @@ const useSendUserToken = (loginType: 'google' | 'apple') => {
const mutationFn = loginType === 'google' ? postUserGoogleToken : postUserAppleToken;

return useMutation({
mutationFn: (data: GoogleTokenData | AppleData) => mutationFn(data),
mutationFn: (data: GoogleTokenData | AppleData) => {
if (loginType === 'google') {
return mutationFn({ access_token: (data as GoogleTokenData).access_token });
} else {
return mutationFn(data);
}
},
onSuccess: async (data) => {
await saveToken(data.accessToken);
setIsLoggedIn(true);
Expand Down
2 changes: 1 addition & 1 deletion src/screens/login/AppleLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const AppleLogin = ({ handleLoginPress }) => {
authorization: identityToken,
user: JSON.stringify({ email, fullName }),
};
sendUserToken.mutate({ token });
sendUserToken.mutate(token);
} else {
console.error('Failed to get identity token');
}
Expand Down
4 changes: 2 additions & 2 deletions src/screens/login/AppleLogin.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ const AppleLoginWeb = ({ handleLoginPress }) => {
onSuccess={async (response) => {
console.log('Apple login response:', response);
try {
const data = {
const token = {
authorization: response.authorization,
user: response.user,
};
sendUserToken.mutate({ token: data });
sendUserToken.mutate(token);
} catch (error) {
console.error('Error during Apple login processing:', error);
}
Expand Down
9 changes: 3 additions & 6 deletions src/screens/login/GoogleLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ const GoogleLogin = ({ handleLoginPress }) => {
const signInWithGoogle = async () => {
try {
await GoogleSignin.hasPlayServices();
const userInfo = await GoogleSignin.signIn();
const token = userInfo.idToken;
console.log('UI', userInfo);
console.log('token', token);
if (token) {
sendUserToken.mutate({ token: token });
const getToken = await GoogleSignin.getTokens();
if (getToken) {
sendUserToken.mutate({ access_token: getToken.accessToken });
}
} catch (error) {
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/login/GoogleLogin.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const GoogleLoginWeb = ({ handleLoginPress }) => {
scope: 'email profile',
onSuccess: async (tokenResponse) => {
console.log(tokenResponse);
sendUserToken.mutate({ token: tokenResponse.access_token });
sendUserToken.mutate({ access_token: tokenResponse.access_token });
},
onError: (error) => {
console.error('Login failed:', error);
Expand Down
14 changes: 13 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@
resolved "https://registry.npmjs.org/@babel/regjsgen/-/regjsgen-0.8.0.tgz"
integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==

"@babel/runtime@^7.0.0", "@babel/runtime@^7.18.6", "@babel/runtime@^7.20.0", "@babel/runtime@^7.8.4":
"@babel/runtime@^7.0.0", "@babel/runtime@^7.18.6", "@babel/runtime@^7.20.0", "@babel/runtime@^7.20.6", "@babel/runtime@^7.8.4":
version "7.24.7"
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz"
integrity sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==
Expand Down Expand Up @@ -4173,6 +4173,11 @@ dotenv-webpack@^8.1.0:
dependencies:
dotenv-defaults "^2.0.2"

dotenv@^16.4.5:
version "16.4.5"
resolved "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz"
integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==

dotenv@^8.2.0:
version "8.6.0"
resolved "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz"
Expand Down Expand Up @@ -7871,6 +7876,13 @@ react-native-date-picker@^5.0.4:
resolved "https://registry.npmjs.org/react-native-date-picker/-/react-native-date-picker-5.0.4.tgz"
integrity sha512-UycNfXGd4ipgdU2a+oZGj7h1nvp8Gz49f/Ko+YdWh6nrBKB49MEp0n9eF1QngbxMKqdK0AdY4udb4IdVVWji4g==

react-native-dotenv@^3.4.11:
version "3.4.11"
resolved "https://registry.npmjs.org/react-native-dotenv/-/react-native-dotenv-3.4.11.tgz"
integrity sha512-6vnIE+WHABSeHCaYP6l3O1BOEhWxKH6nHAdV7n/wKn/sciZ64zPPp2NUdEUf1m7g4uuzlLbjgr+6uDt89q2DOg==
dependencies:
dotenv "^16.4.5"

react-native-element-dropdown@^2.12.1:
version "2.12.1"
resolved "https://registry.npmjs.org/react-native-element-dropdown/-/react-native-element-dropdown-2.12.1.tgz"
Expand Down

0 comments on commit eb0a608

Please sign in to comment.