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

feat!(frontend): reload the page on login / logout success #2432

Merged
merged 46 commits into from
May 27, 2024

Conversation

Lodin
Copy link
Contributor

@Lodin Lodin commented May 15, 2024

Fixes #2235

In addition, introduces onSuccess and navigate callbacks for custom authentication workflows, such as retrieving user info and offline storage.

@Lodin Lodin added the hilla Issues related to Hilla label May 15, 2024
Copy link

codecov bot commented May 15, 2024

Codecov Report

Attention: Patch coverage is 67.85714% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 95.02%. Comparing base (8d50d18) to head (4f49469).

Files Patch % Lines
packages/ts/frontend/src/Authentication.ts 73.07% 4 Missing and 3 partials ⚠️
packages/ts/react-auth/src/useAuth.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2432      +/-   ##
==========================================
- Coverage   95.13%   95.02%   -0.11%     
==========================================
  Files          66       66              
  Lines        4524     4546      +22     
  Branches      648      658      +10     
==========================================
+ Hits         4304     4320      +16     
- Misses        179      182       +3     
- Partials       41       44       +3     
Flag Coverage Δ
unittests 95.02% <67.85%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@platosha platosha changed the title refactor: prefer full page reload instead of AJAX request on logout fix: reload the page on login / logout success May 21, 2024
@platosha platosha force-pushed the fix/auth/logout branch 5 times, most recently from 6b4acde to 2cd96d0 Compare May 22, 2024 08:23
@mshabarov mshabarov requested a review from mcollovati May 24, 2024 06:58
@platosha platosha marked this pull request as ready for review May 24, 2024 15:49
@platosha platosha changed the title fix: reload the page on login / logout success fix!: reload the page on login / logout success May 24, 2024
@platosha platosha changed the title fix!: reload the page on login / logout success feat!: reload the page on login / logout success May 24, 2024
@platosha platosha changed the title feat!: reload the page on login / logout success feat!(frontend): reload the page on login / logout success May 24, 2024
mcollovati
mcollovati previously approved these changes May 24, 2024
Copy link
Contributor

@mcollovati mcollovati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't say much about the implementation, but the issues that caused tests failures due to unexpected redirect to login page, seem to be fixed by using the newly introduced onSuccess callback to store authentication details.
Good job!

Copy link
Contributor Author

@Lodin Lodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
(I cannot approve my own PR)

packages/ts/frontend/src/Authentication.ts Outdated Show resolved Hide resolved
packages/ts/frontend/src/Authentication.ts Outdated Show resolved Hide resolved
packages/ts/frontend/src/Authentication.ts Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented May 27, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@platosha platosha merged commit 7489c24 into main May 27, 2024
13 of 15 checks passed
@platosha platosha deleted the fix/auth/logout branch May 27, 2024 10:28
vaadin-bot pushed a commit that referenced this pull request May 27, 2024
* refactor: prefer full page reload instead of AJAX request on logout

* Revert "refactor: prefer full page reload instead of AJAX request on logout"

This reverts commit 47880c1.

* fix: reload the page on login / logout success

* fix: restore Spring CSRF handling

* fix: normalize redirect as path

* test: prevent flackyness of parallel security tests

* fix(frontend): support context path in redirects

* chore: cleanup

* test(security): verify server-side logout redirect location

* test(security): make tests more reliable

* fix: normalize default redirect URL

* test(security): expect page reload from API

* chore: Java formatting

* fix: more accurate normalize url

* test(security): extra wait for page load

* test(security): extra wait for page load

* test(security): extra wait for page load

* test(security): more explicit load waiting

* chore: cleanup

* test(security): fix load waiting

* chore: Java formatting

* test: add implicit wait

* test: rollback asserting path, use builtin wait for main-view

* test: assertin path using script

* fix: reload with url mapping

* test: wait for invalid session reloads

* chore: remove test logger

* test: extra wait on open

* Revert "test: prevent flackyness of parallel security tests"

This reverts commit 77721ae.

* fix(frontend): prevent following requests when pageReloadNavigation is in use

* Revert "test: add implicit wait"

This reverts commit ed7d66d.

* feat!(frontend): onSuccess login / logout callbacks for custom after-flows

* test: use onSuccess callbacks

* test: wait for load when asserting current URL

* test: apply url mapping to logout path

* chore(frontend): remove unnecessary .toString()

* feat(frontend): support URL in login / logout options

---------

Co-authored-by: Anton Platonov <platosha@gmail.com>
Co-authored-by: Soroosh Taefi <taefi.soroosh@gmail.com>
platosha added a commit that referenced this pull request May 27, 2024
…P: 24.4) (#2481)

feat!(frontend): reload the page on login / logout success (#2432)

* refactor: prefer full page reload instead of AJAX request on logout

* Revert "refactor: prefer full page reload instead of AJAX request on logout"

This reverts commit 47880c1.

* fix: reload the page on login / logout success

* fix: restore Spring CSRF handling

* fix: normalize redirect as path

* test: prevent flackyness of parallel security tests

* fix(frontend): support context path in redirects

* chore: cleanup

* test(security): verify server-side logout redirect location

* test(security): make tests more reliable

* fix: normalize default redirect URL

* test(security): expect page reload from API

* chore: Java formatting

* fix: more accurate normalize url

* test(security): extra wait for page load

* test(security): extra wait for page load

* test(security): extra wait for page load

* test(security): more explicit load waiting

* chore: cleanup

* test(security): fix load waiting

* chore: Java formatting

* test: add implicit wait

* test: rollback asserting path, use builtin wait for main-view

* test: assertin path using script

* fix: reload with url mapping

* test: wait for invalid session reloads

* chore: remove test logger

* test: extra wait on open

* Revert "test: prevent flackyness of parallel security tests"

This reverts commit 77721ae.

* fix(frontend): prevent following requests when pageReloadNavigation is in use

* Revert "test: add implicit wait"

This reverts commit ed7d66d.

* feat!(frontend): onSuccess login / logout callbacks for custom after-flows

* test: use onSuccess callbacks

* test: wait for load when asserting current URL

* test: apply url mapping to logout path

* chore(frontend): remove unnecessary .toString()

* feat(frontend): support URL in login / logout options

---------

Co-authored-by: Vlad Rindevich <vladrin@vaadin.com>
Co-authored-by: Anton Platonov <platosha@gmail.com>
Co-authored-by: Soroosh Taefi <taefi.soroosh@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hilla doesn't redirect to a given URL when logout with Hilla's useAuth API
5 participants