Skip to content

Commit

Permalink
Merge pull request #40 from BOBpossible/feat/#10_LoginAPI
Browse files Browse the repository at this point in the history
Feat/#10 login api
  • Loading branch information
psh320 authored Jul 5, 2022
2 parents 0ce7916 + d5e67a1 commit 8ae5846
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 27 deletions.
14 changes: 9 additions & 5 deletions ios/BOB_FrontEnd.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = BOB_FrontEnd/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = BOB_FrontEnd/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = BOB_FrontEnd/main.m; sourceTree = "<group>"; };
193D3C47DC2D49CAB80AA0A8 /* Poppins-Bold.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = undefined; includeInIndex = 0; lastKnownFileType = unknown; name = "Poppins-Bold.ttf"; path = "../src/assets/fonts/Poppins-Bold.ttf"; sourceTree = "<group>"; };
193D3C47DC2D49CAB80AA0A8 /* Poppins-Bold.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "Poppins-Bold.ttf"; path = "../src/assets/fonts/Poppins-Bold.ttf"; sourceTree = "<group>"; };
3B4392A12AC88292D35C810B /* Pods-BOB_FrontEnd.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BOB_FrontEnd.debug.xcconfig"; path = "Target Support Files/Pods-BOB_FrontEnd/Pods-BOB_FrontEnd.debug.xcconfig"; sourceTree = "<group>"; };
3BDBA311056544AC895D2F63 /* Pretendard-Medium.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "Pretendard-Medium.ttf"; path = "../src/assets/fonts/Pretendard-Medium.ttf"; sourceTree = "<group>"; };
4752C974ABD44F989EB7740B /* Pretendard-SemiBold.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "Pretendard-SemiBold.ttf"; path = "../src/assets/fonts/Pretendard-SemiBold.ttf"; sourceTree = "<group>"; };
Expand All @@ -54,6 +54,7 @@
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = BOB_FrontEnd/LaunchScreen.storyboard; sourceTree = "<group>"; };
89C6BE57DB24E9ADA2F236DE /* Pods-BOB_FrontEnd-BOB_FrontEndTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BOB_FrontEnd-BOB_FrontEndTests.release.xcconfig"; path = "Target Support Files/Pods-BOB_FrontEnd-BOB_FrontEndTests/Pods-BOB_FrontEnd-BOB_FrontEndTests.release.xcconfig"; sourceTree = "<group>"; };
8C92B11A84C940C9822EACEE /* Pretendard-Light.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "Pretendard-Light.ttf"; path = "../src/assets/fonts/Pretendard-Light.ttf"; sourceTree = "<group>"; };
DA4D399328742AD400BCAFF5 /* BOB_FrontEnd.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = BOB_FrontEnd.entitlements; path = BOB_FrontEnd/BOB_FrontEnd.entitlements; sourceTree = "<group>"; };
DAD769892860A37300C84CF1 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -98,6 +99,7 @@
13B07FAE1A68108700A75B9A /* BOB_FrontEnd */ = {
isa = PBXGroup;
children = (
DA4D399328742AD400BCAFF5 /* BOB_FrontEnd.entitlements */,
DAD769892860A37300C84CF1 /* GoogleService-Info.plist */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
13B07FB01A68108700A75B9A /* AppDelegate.mm */,
Expand Down Expand Up @@ -529,8 +531,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = BOB_FrontEnd/BOB_FrontEnd.entitlements;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = Y6DURNJ6AC;
DEVELOPMENT_TEAM = 69F5355JYF;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = BOB_FrontEnd/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -542,7 +545,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.bob-frontend";
PRODUCT_BUNDLE_IDENTIFIER = com.liark.bobplace;
PRODUCT_NAME = BOB_FrontEnd;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand All @@ -556,8 +559,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = BOB_FrontEnd/BOB_FrontEnd.entitlements;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = Y6DURNJ6AC;
DEVELOPMENT_TEAM = 69F5355JYF;
INFOPLIST_FILE = BOB_FrontEnd/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -568,7 +572,7 @@
"-ObjC",
"-lc++",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.bob-frontend";
PRODUCT_BUNDLE_IDENTIFIER = com.liark.bobplace;
PRODUCT_NAME = BOB_FrontEnd;
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
12 changes: 12 additions & 0 deletions ios/BOB_FrontEnd/BOB_FrontEnd.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.applesignin</key>
<array>
<string>Default</string>
</array>
</dict>
</plist>
2 changes: 1 addition & 1 deletion ios/BOB_FrontEnd/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) would like to use your camera</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string/>
<string></string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>$(PRODUCT_NAME) would like to save photos to your photo gallery</string>
<key>NSPhotoLibraryUsageDescription</key>
Expand Down
48 changes: 27 additions & 21 deletions src/screens/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,28 @@ import React, {useCallback, useState, useEffect} from 'react';
import {View, StyleSheet, Text, TouchableOpacity, Image, Platform} from 'react-native';
import {useNavigation} from '@react-navigation/native';
import {SafeAreaView} from 'react-native-safe-area-context';
import appleAuth, {
AppleButton,
AppleAuthRequestOperation,
AppleAuthRequestScope,
AppleAuthCredentialState,
} from '@invertase/react-native-apple-authentication';
import {AppleButton, appleAuth} from '@invertase/react-native-apple-authentication';
import SocialWebviewModal from '../modal/SocialWebviewModal';
import {useRecoilState} from 'recoil';
import {userToken} from '../state';
import auth from '@react-native-firebase/auth';
import axios from 'axios';
import {GoogleSignin, GoogleSigninButton} from '@react-native-google-signin/google-signin';

const onAppleButtonPress = async () => {
// performs login request
const appleAuthRequestResponse = await appleAuth.performRequest({
requestedOperation: AppleAuthRequestOperation.LOGIN,
requestedScopes: [AppleAuthRequestScope.EMAIL, AppleAuthRequestScope.FULL_NAME],
});

// get current authentication state for user
const credentialState = await appleAuth.getCredentialStateForUser(appleAuthRequestResponse.user);

// use credentialState response to ensure the user is authenticated
if (credentialState === AppleAuthCredentialState.AUTHORIZED) {
// user is authenticated
}
};
const Login = ({}) => {
const navigation = useNavigation();
const [token, setToken] = useRecoilState(userToken);
const [loginModal, setLoginModal] = useState(false);
const [source, setSource] = useState('');
const [loggedIn, setLoggedIn] = useState(false);

useEffect(() => {
// onCredentialRevoked returns a function that will remove the event listener. useEffect will call this function when the component unmounts
return appleAuth.onCredentialRevoked(async () => {
console.warn('If this function executes, User Credentials have been Revoked');
});
}, []); // passing in an empty array as the second argument ensures this is only ran once when component mounts initially.

//실행시 구글 로그인 설정 + 로그인 확인 코드
useEffect(() => {
GoogleSignin.configure({
Expand Down Expand Up @@ -64,6 +52,24 @@ const Login = ({}) => {
setLoginModal(true);
};

const onAppleButtonPress = async () => {
// performs login request
const appleAuthRequestResponse = await appleAuth.performRequest({
requestedOperation: appleAuth.Operation.LOGIN,
requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME],
});
// get current authentication state for user
// /!\ This method must be tested on a real device. On the iOS simulator it always throws an error.
const credentialState = await appleAuth.getCredentialStateForUser(
appleAuthRequestResponse.user,
);

// use credentialState response to ensure the user is authenticated
if (credentialState === appleAuth.State.AUTHORIZED) {
const {identityToken, name, email} = appleAuthRequestResponse;
}
};

//
async function onGoogleButtonPress() {
try {
Expand Down

0 comments on commit 8ae5846

Please sign in to comment.