Skip to content

Commit

Permalink
chore: Tidyup
Browse files Browse the repository at this point in the history
  • Loading branch information
jimhunty committed Jun 26, 2023
1 parent a9815a2 commit b0d6277
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 84 deletions.
21 changes: 0 additions & 21 deletions projects/Mallard/src/authentication/authorizers/OktaAuthorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,11 @@ export default new Authorizer({
userDataCache: oktaDataCache,
authCaches: [],
auth: async () => {
// fetch from the service must return a fromResponse
// That fromResponse must include a flat with a ValidResult with the data from user and membership

// okta check gets the user data
// membership check gets the membership data and double flats them together? With a valid result return

// Question: What should we persist to check the user has been authenticated again? How do we reauth?

console.log('GETTING RUN?');
// eslint-disable-next-line
const { access_token } = await oktaAuth();
const data = await authWithTokens(access_token);
console.log('VALID RESULT?: ', data);
return data;

// const casResult = await fetchCASSubscription(subscriberId, password);
// // This "flat" needs to return a valid result
// return flat(casResult, async (expiry) => {
// // Needs to set a cache with whatever comes back? Not sure as the library caches so do we need to reauth?
// // Needs more investigation
// creds.set({
// username: subscriberId,
// token: password,
// });
// return ValidResult(expiry);
// });
},
authWithCachedCredentials: async () => {
const isLoggedIn = await isAuthenticated();
Expand Down
65 changes: 2 additions & 63 deletions projects/Mallard/src/screens/log-in.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { refreshTokens, signOut } from '@okta/okta-react-native';
import React, { useEffect, useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import Image from 'react-native-fast-image';
import type { Source } from 'react-native-fast-image';
import { TouchableOpacity } from 'react-native-gesture-handler';
import { oktaAuth, oktaInitialisation } from 'src/authentication/services/okta';
import { Button } from 'src/components/Button/Button';
import { Link, LinkNav } from 'src/components/link';
import { LoginButton } from 'src/components/login/login-button';
Expand Down Expand Up @@ -90,7 +87,6 @@ const Login = ({
onApplePress,
onGooglePress,
onAppleOAuthPress,
onOktaPress,
onSubmit,
onDismiss,
isLoading,
Expand All @@ -104,7 +100,6 @@ const Login = ({
onApplePress: () => void;
onGooglePress: () => void;
onAppleOAuthPress: () => void;
onOktaPress: () => void;
email: FormField;
password: FormField;
onSubmit: () => void;
Expand All @@ -119,8 +114,6 @@ const Login = ({
const [hasInputEmail, setHasInputEmail] = useState(false);
const [showError, setShowError] = useState(false);

useEffect(() => oktaInitialisation(), []);

const onInputChange = (fn: (value: string) => void) => (value: string) => {
const email = value.trim();
setShowError(false);
Expand Down Expand Up @@ -227,60 +220,6 @@ const Login = ({
Have a subscription but cannot sign in?
</LinkNav>
</View>
<View>
<TouchableOpacity onPress={onOktaPress}>
<Text
style={{
fontSize: 20,
padding: 20,
color: 'black',
}}
>
LOGIN WITH OKTA
</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={async () => {
try {
const attempt = await signOut();
console.log(attempt);
} catch (e) {
console.log(e);
}
}}
>
<Text
style={{
fontSize: 20,
padding: 20,
color: 'black',
}}
>
LOGOUT WITH OKTA
</Text>
</TouchableOpacity>

<TouchableOpacity
onPress={async () => {
try {
const attempt = await refreshTokens();
console.log(attempt);
} catch (e) {
console.log(e);
}
}}
>
<Text
style={{
fontSize: 20,
padding: 20,
color: 'black',
}}
>
REFRESH OKTA TOKENS
</Text>
</TouchableOpacity>
</View>
</View>
</LoginLayout>
);
Expand Down

0 comments on commit b0d6277

Please sign in to comment.