Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/oauth improve #155

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion TERMTERM/src/components/terms/WordCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Animated, {
useSharedValue,
} from "react-native-reanimated";
import Carousel from "react-native-reanimated-carousel";
import { screenWidth } from "@style/dimensions";
import { screenHeight, screenWidth } from "@style/dimensions";
import { WordProps } from "@interfaces/word";
import WordCard from "./WordCard";
import { useThemeStyle } from "@hooks/useThemeStyle";
Expand Down Expand Up @@ -62,6 +62,7 @@ const WordCarousel = ({
{...baseOptions}
style={{
width: screenWidth,
height: 370,
}}
loop={words.length > 1}
pagingEnabled={true}
Expand Down
20 changes: 19 additions & 1 deletion TERMTERM/src/screens/Webview/KakaoLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { View } from "react-native";
import { WebView } from "react-native-webview";
import { WebView, WebViewNavigation } from "react-native-webview";
import { StackScreenProps } from "@react-navigation/stack";
import { RootStackParamList } from "@interfaces/RootStackParamList";
import { KAKAO_CLIENT_ID, KAKAO_REDIRECT_URI } from "@api/secret";
Expand All @@ -8,6 +8,7 @@ import { setAccessToken, setRefreshToken } from "@utils/tokenHandler";
import MemberApi from "@api/MemberApi";
import { MemberInfo } from "Member";
import { loginFailed, loginSucceed, needRegister } from "@utils/showToast";
import { Linking, Platform } from "react-native";

export type HomeScreenProps = StackScreenProps<RootStackParamList, "Kakao">;

Expand All @@ -17,6 +18,21 @@ const KakaoLogin = ({ navigation }: HomeScreenProps) => {
const authApi = new AuthApi();
const memberApi = new MemberApi();

// Mozilla/5.0 (Linux; Android 8.0.0; SM-G935S Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Mobile Safari/537.36
const customUserAgent =
"Mozilla/5.0 (Linux; Android 8.0.0; SM-G935S Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Mobile Safari/537.36";

const onShouldStartLoadWithRequest = (
request: WebViewNavigation
): boolean => {
console.log(request);
if (request.url.startsWith("kakaotalk://")) {
Linking.openURL(request.url);
return false;
}
return true;
};

const logInProgress = (data: any) => {
const exp = "code=";

Expand Down Expand Up @@ -69,6 +85,8 @@ const KakaoLogin = ({ navigation }: HomeScreenProps) => {
onMessage={(event) => {
logInProgress(event.nativeEvent.url);
}}
userAgent={customUserAgent}
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
/>
</View>
);
Expand Down