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

Nudge people to the organisation login if OIDC enabled. #4349

Merged
merged 3 commits into from
Jun 10, 2024

Conversation

joeribekker
Copy link
Contributor

@joeribekker joeribekker commented Jun 3, 2024

Closes #4347

Changes

Hides the form when OIDC is disabled. Note that this is not the best code, but it shows the intent of what I want. It has 2 aspects: 1) nicer and better visible -or-, 2) less nudge towards form login

msedge_yrdXJ7k9O5

Checklist

Check off the items that are completed or not relevant.

  • Impact on features

    • Checked copying a form
    • Checked import/export of a form
    • Config checks in the configuration overview admin page
    • Problem detection in the admin email digest is handled
  • Release management

    • I have labelled the PR as "needs-backport" accordingly
  • I have updated the translations assets (you do NOT need to provide translations)

    • Ran ./bin/makemessages_js.sh.sh
    • Ran ./bin/compilemessages_js.sh
  • Commit hygiene

    • Commit messages refer to the relevant Github issue
    • Commit messages explain the "why" of change, not the how

@joeribekker joeribekker requested a review from stevenbal June 3, 2024 15:33
@joeribekker
Copy link
Contributor Author

@stevenbal could you prettify this code and port it?

Copy link

codecov bot commented Jun 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.26%. Comparing base (4c62dcf) to head (928484d).
Report is 727 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4349   +/-   ##
=======================================
  Coverage   96.26%   96.26%           
=======================================
  Files         731      731           
  Lines       23786    23787    +1     
  Branches     2803     2803           
=======================================
+ Hits        22898    22899    +1     
  Misses        617      617           
  Partials      271      271           

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

@stevenbal stevenbal self-assigned this Jun 4, 2024
@@ -1,11 +1,14 @@
{% extends "maykin_2fa/login.html" %}
Copy link
Contributor

Choose a reason for hiding this comment

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

@joeribekker I'm not sure if I can port this to mozilla-django-oidc-db easily, since our template extends the login template from maykin_2fa currently. I could maybe create a snippet for the extra login options in mozilla-django-oidc-db that is included here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe port it to default project, as that is our glue for all projects

@stevenbal stevenbal requested a review from sergei-maertens June 4, 2024 13:32
src/openforms/js/components/admin/login.js Outdated Show resolved Hide resolved
src/openforms/templates/maykin_2fa/login.html Outdated Show resolved Hide resolved
src/openforms/templates/maykin_2fa/login.html Show resolved Hide resolved
Comment on lines 118 to 124
/**
* mozilla-django-oidc-db
* hide the regular admin login form by default if OIDC is enabled
*/
#login-form:has(~ .admin-login-oidc) {
display: none;
}
Copy link
Member

Choose a reason for hiding this comment

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

I think I'd make these selectors more component-oriented with the proposed class names to follow BEM methodology.

.admin-login-option {
  @include bem.modifier('username') {
    ~ .admin-login-option--oidc {
      display: none;
    }
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

But the rule at line 122 is meant to set display: none; on the #login-form itself, whereas your suggestion hides the OIDC option instead (if I understand it correctly)?

Copy link
Member

Choose a reason for hiding this comment

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

I didn't try out the actual CSS, so yeah, probably should throw in a :has(...) in there! My point was more about using the BEM methodology :)

src/openforms/scss/admin/_app_overrides.scss Outdated Show resolved Hide resolved
src/openforms/scss/admin/_app_overrides.scss Outdated Show resolved Hide resolved
Comment on lines 100 to 103
&--disabled {
display: none;
}
Copy link
Member

Choose a reason for hiding this comment

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

can you please use the mixins like in the sample I gave? These exist because the resulting selector now is .admin-login-option--disabled, and with the mixin it is .admin-login-option.admin-login-option--disabled.

A classname with modifier may not exist without the block/element itself, these sass mixins help enforce this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I added it for .admin-login-option--disabled, though I'm not sure if this works for the #login-form block, because it's an id instead of a class 🤔

Copy link
Member

Choose a reason for hiding this comment

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

yeah it doesn't work with IDs, since the whole idea of BEM is class-names :) for those you can spell them out manually entirely. ID's are an anti-pattern anyway for styling, I dislike that Django uses them so much in their CSS :(

* use `onLoaded` instead to add admin form toggle functionality
* use BEM syntax for admin login options
* fix admin-login-divider styling and use CSS var instead of hardcoded colors
@stevenbal stevenbal force-pushed the feature/better-login-ux branch from 8c5539f to 928484d Compare June 10, 2024 14:37
@sergei-maertens sergei-maertens merged commit a27ae39 into master Jun 10, 2024
26 checks passed
@sergei-maertens sergei-maertens deleted the feature/better-login-ux branch June 10, 2024 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make logging in with username/password less prominent when OIDC is enabled
3 participants