This commit is contained in:
Wojciech Todryk 2012-03-10 21:03:56 +01:00
parent cacd9575d0
commit 7de07db812
8 changed files with 46 additions and 41 deletions

View file

@ -13,13 +13,19 @@ class UserController < ApplicationController
end end
def authenticate def authenticate
users = User.all
if users.count.zero?
redirect_to :controller => 'user', :action => 'setup'
return false
end
if not $defaults["only_can_logins"].nil? if not $defaults["only_can_logins"].nil?
if not $defaults["only_can_logins"].include?(params[:user][:login]) if not $defaults["only_can_logins"].include?(params[:user][:login])
redirect_to :controller => 'internal', :action => 'onlycanlogins' redirect_to :controller => 'internal', :action => 'onlycanlogins'
return false return false
end end
end end
user = User.find_by_login(params[:user][:login]) user = User.find_by_login(params[:user][:login])
if user.nil? if user.nil?

View file

@ -0,0 +1,4 @@
.control-group
.controls
%button{:class=>"btn btn-primary",:type=>"submit"}
= text

View file

@ -0,0 +1,8 @@
- model = eval(object.class.model_name)
- label.nil? ? model_label = model.human_attribute_name(attr) : model_label = t(label.to_sym)
.control-group
%label{:class=>"control-label",:for=>"#{attr}"}
= model_label
.controls
%input{:id=>"#{model}_#{attr}",:name=>"#{model}[#{attr}]"}

View file

@ -0,0 +1,5 @@
.control-group
%label{:class=>"control-label",:for=>"#{attr}"}
= model.capitalize.constantize.human_attribute_name(attr)
.controls
%input{:id=>"#{model}_#{attr}",:name=>"#{model}[#{attr}]"}

View file

@ -15,7 +15,6 @@
%a{:href=>"/"} %a{:href=>"/"}
= image_tag "logo.png" = image_tag "logo.png"
.row .row
%hr/
- if flash[:error] - if flash[:error]
.alert.alert-error .alert.alert-error
= flash[:error] = flash[:error]

View file

@ -1,18 +1,12 @@
- content_for :title do
\-
= t(:login,:scope=>:user)
%form{:class=>"form-horizontal top-pix18",:action=>"#{url_for(:controller => 'user', :action => 'authenticate')}",:method=>"post"} %form{:class=>"form-horizontal top-pix18",:action=>"#{url_for(:controller => 'user', :action => 'authenticate')}",:method=>"post"}
%fieldset %fieldset
.control-group = render :partial => "common/input_form_field",:locals => { :model => 'user',:attr => 'login'}
%label{:class=>"control-label",:for=>"login"} = render :partial => "common/input_form_field",:locals => { :model => 'user',:attr => 'password'}
= User.human_attribute_name('login') = render :partial => "common/form_button",:locals => { :text => t(:please_login,:scope=>:user)}
.controls
%input{:id=>"user_login",:name=>"user[login]"}
.control-group
%label{:class=>"control-label",:for=>"password"}
= User.human_attribute_name('password')
.controls
%input{:id=>"user_password",:name=>"user[password]"}
.control-group
.controls
%button{:class=>"btn btn-primary",:type=>"submit"}
= t(:please_login,:scope=>:user)

View file

@ -1,20 +0,0 @@
<% content_for :title do %>
<%= t(:setup,:scope=>:user) %>
<% end %>
<div class="box">
<div class="box2">
<div class="logo"><a href="/"><img src="<%= current_theme_image_path('logo_small.png')%>" alt="<%= t(:mailr,:scope=>:common) %>"/></a>
</div>
<h2><%= t(:setup,:scope=>:user) %></h2>
<div class="content">
<form action="<%=url_for(:controller => 'user', :action => 'create')%>" method="post" class="form">
<%= raw form_field(@user,"login",nil,"joe.doe",params[:user].nil? ? params[:login] : params[:user][:login]) %>
<%= raw form_field(@user,"first_name",nil,"Joe","") %>
<%= raw form_field(@user,"last_name",nil,"Doe","") %>
<%= raw form_field(@server,"name",nil,"server.domain","") %>
<%= raw single_action('send','compose',"up.png") %>
</form>
</div>
</div>
</div>

9
app/views/user/setup.html.haml Executable file
View file

@ -0,0 +1,9 @@
- content_for :title do
\-
= t(:setup,:scope=>:user)
%form{:class=>"form-horizontal top-pix18",:action=>"#{url_for(:controller => 'user', :action => 'create')}",:method=>"post"}
%legend
= t(:setup,:scope=>:user)
%fieldset
= render :partial => "common/input_form_desc_field",:locals => {:object => @user,:attr => 'login',:label => nil,:example => 'joe doe',:value => params[:user].nil? ? params[:login] : params[:user][:login]}