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

Fix display LogInComponent turning blank when entering wrong username/password combination #2530

Conversation

alexandrevryghem
Copy link
Member

@alexandrevryghem alexandrevryghem commented Sep 27, 2023

References

Description

Fixes bug where the LogInComponent turns blank when submitting invalid username/password combination.

Instructions for Reviewers

Instead of hiding the LogInContainerComponent by checking it's content, now it hides it by checking if the login method has a component with a rendersAuthMethodType decorator.

Guidance for how to test or review this PR:
You can test it locally but I wasn't able to reproduce the bug myself with my local setup

Checklist

  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using yarn lint
  • My PR doesn't introduce circular dependencies (verified via yarn check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@alexandrevryghem alexandrevryghem self-assigned this Sep 27, 2023
@tdonohue tdonohue added the port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release label Sep 27, 2023
@tdonohue tdonohue added this to the 7.6.1 milestone Sep 27, 2023
@alanorth alanorth changed the title Fix display LogInComponent turning black when entering wrong username/password combination Fix display LogInComponent turning blank when entering wrong username/password combination Sep 28, 2023
@alanorth
Copy link
Contributor

alanorth commented Oct 4, 2023

Reviewed by testing on DSpace 7.6.

I haven't managed to pinpoint the circumstances where it occurs, but I get a blank login menu very frequently when running in dev mode. With this patch I have not noticed the blank menu even once, and everything is working as normal as far as I can tell. I'm +1 by testing. Haven't reviewed the code yet.

@tdonohue tdonohue requested a review from atarix83 October 5, 2023 14:48
Copy link
Contributor

@vins01-4science vins01-4science left a comment

Choose a reason for hiding this comment

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

Hello @alexandrevryghem ,

thank you for this PR, I've tested its behavior and it seems to fix that issue.
I'm glad you fixed it, but I think that we can improve the code by not using the ElementRef and the d-none class. Instead we should filter out for all the AuthMethodType not configured by extending the filter

      map((methods: AuthMethod[]) => methods.filter((authMethod: AuthMethod) => authMethod.authMethodType !== AuthMethodType.Ip)),

inside the log-in.component.ts by using the new method inside the log-in.methods-decorator.ts.

I would like to ask for these changes, Do you agree with these requests?

Thank you.

Comment on lines 57 to 61
const component = rendersAuthMethodType(this.authMethod.authMethodType);
if (component === undefined) {
this.elRef.nativeElement.classList.add('d-none');
}
return component;
Copy link
Contributor

Choose a reason for hiding this comment

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

If the problem is that the component is undefined, it would be better to filter out all the authMethodType that are not configured. To achieve this behavior, you should filter them inside the log-in-component and add the related method inside the login-in.methods-decorator.
Do you agree @alexandrevryghem?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thnx for the review @vins01-4science, I indeed do agree that it would be even better to filter them out earlier so that it never even generates a LogInContainerComponent for AuthMethods without a Component. But I would prefer to just check if the Component is undefined though, so that it works dynamically, independently of which (future) AuthMethods are added.

src/app/shared/log-in/methods/log-in.methods-decorator.ts Outdated Show resolved Hide resolved
@alexandrevryghem alexandrevryghem force-pushed the fix-display-order-authentication-methods_contribute-7.6 branch from bc34511 to b778c74 Compare October 21, 2023 15:08
…en the searchByObject request doesn't succeed
…' into fix-display-order-authentication-methods_contribute-7.6

# Conflicts:
#	src/app/shared/log-in/log-in.component.html
#	src/app/shared/log-in/log-in.component.ts
@alexandrevryghem alexandrevryghem force-pushed the fix-display-order-authentication-methods_contribute-7.6 branch from b778c74 to b8eaf90 Compare October 21, 2023 16:20
@alexandrevryghem
Copy link
Member Author

@vins01-4science, I implemented your feedback, and I also added a small commit to fix an error that I found while making the updates.
When you are running Angular, but your backend is down, the error ERROR TypeError: authorizations.filter is not a function is logged. This error occurs because AuthorizationDataService#isAuthorized returns false when an error is thrown, and oneAuthorizationMatchesFeature tries to iterate over it, which is obviously not possible. To fix this, an empty array needs to be returned, and this will still result in an observableOf(false) being returned by AuthorizationDataService#isAuthorized.

Copy link
Contributor

@vins01-4science vins01-4science left a comment

Choose a reason for hiding this comment

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

Thank you @alexandrevryghem for the changes, everything seems to be correct to me 🚀 .
I am 👍 on this one.

Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

👍 Thanks @alexandrevryghem ! Verified this fixes the bug & that reordering of login options (Shib, Password, etc) still works properly

@tdonohue tdonohue merged commit daef3f5 into DSpace:main Oct 25, 2023
10 checks passed
@dspace-bot
Copy link
Contributor

Backport failed for dspace-7_x, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally.

git fetch origin dspace-7_x
git worktree add -d .worktree/backport-2530-to-dspace-7_x origin/dspace-7_x
cd .worktree/backport-2530-to-dspace-7_x
git checkout -b backport-2530-to-dspace-7_x
ancref=$(git merge-base bf8519cc9484c144d58019c99ee65df58108dbb7 b8eaf90b03a3accd436356b85e8c7669f23eda0e)
git cherry-pick -x $ancref..b8eaf90b03a3accd436356b85e8c7669f23eda0e

@tdonohue
Copy link
Member

Ported to 7.6.x manually via #2575

@tdonohue tdonohue removed the port to dspace-7_x This PR needs to be ported to `dspace-7_x` branch for next bug-fix release label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

When you enter the wrong username/password combination, the login dropdown turns blank
5 participants