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

Allow customization of the login form? #1098

Open
felagund opened this issue Nov 8, 2022 · 2 comments
Open

Allow customization of the login form? #1098

felagund opened this issue Nov 8, 2022 · 2 comments

Comments

@felagund
Copy link

felagund commented Nov 8, 2022

I am not sure if this is up to omniauth or its users, but would it be possible to add customization options for the login screen itself?

Looking at https://github.com/omniauth/omniauth/blob/a62d36b3f847e0e55b077790112e96950c35085a/lib/omniauth/form.rb

I imagine there could be a hook to include some code after or before the form element.

The use case would be to put a link to password renewal there. I am coming from here: jonmbake/discourse-ldap-auth#61

@BobbyMcWho
Copy link
Member

You can insert whatever html you want using the OmniAuth::Form#html method.

Here's where your LDAP strategy is building its form.

I'm not sure how you'd manage all the inner workings using jonmbake/discourse-ldap-auth, but using an omniauth strategy you'd

class Omniauth::Strategies::MyCustomLDAP < Omniauth::Strategies::LDAP
  def request_phase
    OmniAuth::LDAP::Adaptor.validate @options
    f = OmniAuth::Form.new(:title => (options[:title] || "LDAP Authentication"), :url => callback_path)
    f.text_field 'Login', 'username'
    f.password_field 'Password', 'password'
    f.button "Sign In"
    f.html '<a href="https://my-password-reset-url.com">Reset Password</a>'
    f.to_response
  end
end

@felagund
Copy link
Author

felagund commented Nov 8, 2022

Thanks, that should do the trick! Eventually, after some figuring out:-).

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

No branches or pull requests

2 participants