Skip to content

Commit

Permalink
- Fixed autoregistration and enabled manual login
Browse files Browse the repository at this point in the history
Continued fixing minor issues brought up on issue AdamLantos#18.
- Self-Registration form is working (although it is not used by my installations)
- Logout now returns to login screen allowing the user to change identity
- Locked users cannot log in
  • Loading branch information
ma-ku committed Apr 16, 2013
1 parent b7c2d14 commit 91337a5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/controllers/registration_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class RegistrationController < ApplicationController
def autoregistration_form
@user = User.new :language => Setting.default_language
set_default_attributes @user
logger.info "Hallo Welt"
end

def register
Expand All @@ -22,8 +23,7 @@ def register
end

def autoregistration_enabled
unless Setting.
plugin_redmine_http_auth['auto_registration'] == "true"
unless Setting.plugin_redmine_http_auth['auto_registration'] == "true"

flash[:error] = l :error_autoregistration_disabled
redirect_to home_url
Expand Down
27 changes: 9 additions & 18 deletions app/views/registration/autoregistration_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
<h2><%=l(:label_autoregister)%></h2>

<% form_tag({:action => 'register'}, :class => "tabular") do %>
<%= labelled_form_for @user, :url => { :action => "register" } do |f| %>
<%= error_messages_for 'user' %>

<div class="box">
<!--[form:user]-->
<p><label for="user_login"><%=l(:field_login)%> <span class="required">*</span></label>
<%= text_field 'user', 'login', :size => 25, :disabled => (readonly_attribute? 'login') %></p>
<div class="box tabular">
<p><%= f.text_field :login, :size => 25, :required => true %></p>
<p><%= f.text_field :firstname, :required => true %></p>
<p><%= f.text_field :lastname, :required => true %></p>
<p><%= f.text_field :mail, :required => true %></p>
<p><%= f.select :language, lang_options_for_select %></p>

<p><label for="user_firstname"><%=l(:field_firstname)%> <span class="required">*</span></label>
<%= text_field 'user', 'firstname', :disabled => (readonly_attribute? 'firstname') %></p>

<p><label for="user_lastname"><%=l(:field_lastname)%> <span class="required">*</span></label>
<%= text_field 'user', 'lastname', :disabled => (readonly_attribute? 'lastname') %></p>

<p><label for="user_mail"><%=l(:field_mail)%> <span class="required">*</span></label>
<%= text_field 'user', 'mail', :disabled => (readonly_attribute? 'mail') %></p>

<p><label for="user_language"><%=l(:field_language)%></label>
<%= select("user", "language", lang_options_for_select) %></p>

<!--[eoform:user]-->
</div>

<%= submit_tag l(:button_submit) %>
<% end %>


18 changes: 18 additions & 0 deletions lib/redmine_http_auth/account_controller_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module RedmineHttpAuth
module AccountControllerPatch
def self.included(base)
base.class_eval do
# We're substituting the original function since redirect_to can only be called once and we need to change the target page
def logout
logout_user
if Setting.plugin_redmine_http_auth['enable'] == "true"
redirect_to signin_url
else
redirect_to home_url
end
end
end
end
end
end

2 comments on commit 91337a5

@jendamek
Copy link

Choose a reason for hiding this comment

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

Hi,

I have tried to install your plugin in latest Redmine stable release (2.5.1), but when restarting the server I keep getting the following error:

ActionController::RoutingError (No route matches {:controller=>"httpauth-login"}):
lib/redmine/menu_manager.rb:150:in render_single_menu_node' lib/redmine/menu_manager.rb:102:inrender_menu_node'
lib/redmine/menu_manager.rb:91:in block in render_menu' lib/redmine/menu_manager.rb:168:inblock in menu_items_for'
lib/redmine/menu_manager.rb:165:in each' lib/redmine/menu_manager.rb:165:inmenu_items_for'
lib/redmine/menu_manager.rb:90:in render_menu' app/views/layouts/base.html.erb:23:in_app_views_layouts_base_html_erb__3645520945912230717_23871320'

I have no knowledge about the Rails or Ruby, could anyone please point me in the right direction for solving this problem?

Best regards

Jan Mach

@jendamek
Copy link

Choose a reason for hiding this comment

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

Hi everybody,

I managed to solve the problem I was having, so I decided to paste my solution here (in case someone else is also using it, it seems suspiciously dead to me):

--- redmine_http_auth/init.rb.orig      2014-04-30 14:12:14.949674538 +0200
+++ redmine_http_auth/init.rb   2014-04-30 14:10:46.216099200 +0200
@@ -8,7 +8,7 @@
   url 'http://github.com/AdamLantos/redmine_http_auth' if respond_to?(:url)
   description 'A plugin for doing HTTP authentication'
   version '0.3.0-dev-redmine-2.x'
-  menu :account_menu, :login_httpauth, { :controller => 'httpauth-login' }, 
+  menu :account_menu, :login_httpauth,'httpauth-login', 
     :before => :login, :caption => :login_httpauth_title,
     :if => Proc.new { User.current.anonymous? && Setting.plugin_redmine_http_auth['enable'] == 'true' }

Please sign in to comment.