-
Notifications
You must be signed in to change notification settings - Fork 4
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
Using current_user endpoint to fetch the authenticated user #41
Conversation
77a79db
to
53b8d7a
Compare
@@ -98,7 +96,7 @@ export default function SignIn() { | |||
} | |||
|
|||
try { | |||
const tokenResponse = await fetch( | |||
await fetch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May want to make this a constant string somewhere.
@@ -7,13 +7,25 @@ import { Text, View } from '../components/Themed'; | |||
export default function TabOneScreen() { | |||
const { user } = useUser(); | |||
const { signOut } = useSignOut(); | |||
// not sure why but this constantly fires over and over again probably a bug w/ how context was set up | |||
console.log('user', user); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we delete this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
const response = await fetch( | ||
`${process.env['EXPO_PUBLIC_API_URL']}/current-user/`, | ||
{ | ||
credentials: 'include', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some more reading it is possible we do not want credentials: 'include'
. I believe we want to use the default same origin policy. We can update the backend to support this.
I think we'll need to configure
CORS_ALLOWED_ORIGINS = [
"https://sub1.example.com",
"https://sub2.example.com",
]
and
SESSION_COOKIE_DOMAIN = ".example.com"
router.replace('/'); | ||
} | ||
} | ||
const userData = await fetchUser(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to have a conversation about the automatic cookie handling in react native.
facebook/react-native#23185
https://stackoverflow.com/a/41637805
https://reactnative.dev/docs/network#known-issues-with-fetch-and-cookie-based-authentication
* server, betterangels starting commands * stuck on backend * initial * fetch current user * Added a few things * adding fetch user * chagne back to local host * loop bug fix * adding fetched user endpoint * updated session and user fetch * dev env check * removed log --------- Co-authored-by: Davit-BetterAngels <davit@betterangels.la> Co-authored-by: Davit-BetterAngels <141072810+Davit-BetterAngels@users.noreply.github.com>
No description provided.