upd: login
Deskripsi: - login token - logout No Issues
This commit is contained in:
@@ -4,10 +4,22 @@ import HeaderRightDivisionList from "@/components/division/headerDivisionList";
|
||||
import HeaderMemberList from "@/components/member/headerMemberList";
|
||||
import HeaderRightProjectList from "@/components/project/headerProjectList";
|
||||
import { Headers } from "@/constants/Headers";
|
||||
import { router, Stack } from "expo-router";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Redirect, router, Stack } from "expo-router";
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import { Text } from "react-native";
|
||||
|
||||
export default function RootLayout() {
|
||||
const { token, isLoading } = useAuthSession()
|
||||
|
||||
if (isLoading) {
|
||||
return <Text>Loading...</Text>;
|
||||
}
|
||||
|
||||
if (!token?.current) {
|
||||
return <Redirect href="/" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack screenOptions={Headers.shadow}>
|
||||
|
||||
@@ -3,11 +3,14 @@ import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||
import { ButtonHeader } from "@/components/buttonHeader";
|
||||
import ItemDetailMember from "@/components/itemDetailMember";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Octicons } from "@expo/vector-icons";
|
||||
import { router, Stack } from "expo-router";
|
||||
import { Image, SafeAreaView, ScrollView, Text, View } from "react-native";
|
||||
|
||||
export default function Profile() {
|
||||
const {signOut, token} = useAuthSession()
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
<Stack.Screen
|
||||
@@ -22,7 +25,8 @@ export default function Profile() {
|
||||
AlertKonfirmasi({
|
||||
title: 'Keluar',
|
||||
desc: 'Apakah anda yakin ingin keluar?',
|
||||
onPress: () => { router.push('/') }
|
||||
// onPress: () => { router.push('/') }
|
||||
onPress: () => { signOut()}
|
||||
})
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import AuthProvider from '@/providers/AuthProvider';
|
||||
import { useFonts } from 'expo-font';
|
||||
import { Stack } from 'expo-router';
|
||||
import * as SplashScreen from 'expo-splash-screen';
|
||||
@@ -25,13 +26,14 @@ export default function RootLayout() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<Stack.Screen name="index" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="verification" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="(application)" options={{ headerShown: false }} />
|
||||
</Stack>
|
||||
<StatusBar style="auto" />
|
||||
|
||||
<AuthProvider>
|
||||
<Stack>
|
||||
<Stack.Screen name="index" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="verification" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="(application)" options={{ headerShown: false }} />
|
||||
</Stack>
|
||||
<StatusBar style="auto" />
|
||||
</AuthProvider>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
import { ButtonForm } from "@/components/buttonForm";
|
||||
import { InputForm } from "@/components/inputForm";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { router } from "expo-router";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { Redirect, router } from "expo-router";
|
||||
import { Image, Text, View } from "react-native";
|
||||
|
||||
export default function Index() {
|
||||
const { token, isLoading } = useAuthSession()
|
||||
if (isLoading) {
|
||||
return <Text>Loading...</Text>;
|
||||
}
|
||||
|
||||
if (token?.current) {
|
||||
return <Redirect href="/home" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={Styles.wrapLogin} >
|
||||
<View style={{ alignItems: "center", marginVertical: 50 }}>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ButtonForm } from "@/components/buttonForm";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { router } from "expo-router";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import CryptoES from "crypto-es";
|
||||
import React, { useState } from "react";
|
||||
import { Image, Text, View } from "react-native";
|
||||
import { CodeField, Cursor, useBlurOnFulfill, useClearByFocusCell, } from 'react-native-confirmation-code-field';
|
||||
@@ -13,7 +14,17 @@ export default function Index() {
|
||||
setValue,
|
||||
});
|
||||
|
||||
|
||||
const { signIn } = useAuthSession();
|
||||
const login = (): void => {
|
||||
const random: string = 'contohLoginMobileDarmasaba';
|
||||
var mytexttoEncryption = "contohLoginMobileDarmasaba"
|
||||
const encrypted = CryptoES.AES.encrypt(mytexttoEncryption, "your password").toString();
|
||||
// var C = require("crypto-js");
|
||||
// var Decrypted = C.AES.decrypt(encrypted, "your password");
|
||||
// var result = Decrypted.toString(C.enc.Utf8);
|
||||
// console.log(encrypted,result);
|
||||
signIn(encrypted);
|
||||
}
|
||||
return (
|
||||
<View style={Styles.wrapLogin} >
|
||||
<View style={{ alignItems: "center", marginVertical: 50 }}>
|
||||
@@ -45,7 +56,11 @@ export default function Index() {
|
||||
</Text>
|
||||
)}
|
||||
/>
|
||||
<ButtonForm text="SUBMIT" onPress={() => { router.push("/home") }} />
|
||||
<ButtonForm
|
||||
text="SUBMIT"
|
||||
// onPress={() => { router.push("/home") }}
|
||||
onPress={login}
|
||||
/>
|
||||
<Text style={[Styles.textInformation, Styles.mt05, Styles.cDefault, { textAlign: 'center' }]}>
|
||||
Tidak Menerima kode verifikasi? Kirim Ulang
|
||||
</Text>
|
||||
|
||||
Reference in New Issue
Block a user