-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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/28925: Anonymous user can edit profile #29248
Changes from all commits
c92ab2e
fa0fc43
78ba2a4
709d48f
0d08b32
51cd993
03af648
0ac3e98
ce65315
ced932a
dfddd33
a14e7ff
d0983f9
70e068d
bcfdc7e
bf8bec8
1cb4cc1
3ff9451
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -871,6 +871,33 @@ function waitForUserSignIn(): Promise<boolean> { | |
}); | ||
} | ||
|
||
/** | ||
* check if the route can be accessed by anonymous user | ||
* | ||
* @param {string} route | ||
*/ | ||
|
||
const canAccessRouteByAnonymousUser = (route: string) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const reportID = ReportUtils.getReportIDFromLink(route); | ||
if (reportID) { | ||
return true; | ||
} | ||
const parsedReportRouteParams = ReportUtils.parseReportRouteParams(route); | ||
let routeRemovedReportId = route; | ||
if ((parsedReportRouteParams as {reportID: string})?.reportID) { | ||
routeRemovedReportId = route.replace((parsedReportRouteParams as {reportID: string})?.reportID, ':reportID'); | ||
} | ||
if (route.startsWith('/')) { | ||
routeRemovedReportId = routeRemovedReportId.slice(1); | ||
} | ||
const routesCanAccessByAnonymousUser = [ROUTES.SIGN_IN_MODAL, ROUTES.REPORT_WITH_ID_DETAILS.route, ROUTES.REPORT_WITH_ID_DETAILS_SHARE_CODE.route]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed here: #37952 |
||
|
||
if ((routesCanAccessByAnonymousUser as string[]).includes(routeRemovedReportId)) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
|
||
export { | ||
beginSignIn, | ||
beginAppleSignIn, | ||
|
@@ -900,4 +927,5 @@ export { | |
toggleTwoFactorAuth, | ||
validateTwoFactorAuth, | ||
waitForUserSignIn, | ||
canAccessRouteByAnonymousUser, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ function SignInModal() { | |
shouldEnableMaxHeight | ||
testID={SignInModal.displayName} | ||
> | ||
<HeaderWithBackButton /> | ||
<HeaderWithBackButton onBackButtonPress={Navigation.dismissModal} /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This caused inconsistency between browser back button and modal back button. (Coming from #33417) |
||
<SignInPage isInModal /> | ||
</ScreenWrapper> | ||
); | ||
|
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.
Updating this comment (or adding a comment in the function) to say why an anonymous user can only access different routes would be helpful for future programmers like me who don't have context on why this exists (in general, comments should be used to explain why the code is like that, not what the code is obviously doing)