cont
This commit is contained in:
parent
cacd9575d0
commit
7de07db812
|
@ -13,13 +13,19 @@ class UserController < ApplicationController
|
|||
end
|
||||
|
||||
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"].include?(params[:user][:login])
|
||||
redirect_to :controller => 'internal', :action => 'onlycanlogins'
|
||||
return false
|
||||
end
|
||||
end
|
||||
if not $defaults["only_can_logins"].nil?
|
||||
if not $defaults["only_can_logins"].include?(params[:user][:login])
|
||||
redirect_to :controller => 'internal', :action => 'onlycanlogins'
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
user = User.find_by_login(params[:user][:login])
|
||||
if user.nil?
|
||||
|
|
4
app/views/common/_form_button.html.haml
Executable file
4
app/views/common/_form_button.html.haml
Executable file
|
@ -0,0 +1,4 @@
|
|||
.control-group
|
||||
.controls
|
||||
%button{:class=>"btn btn-primary",:type=>"submit"}
|
||||
= text
|
8
app/views/common/_input_form_desc_field.html.haml
Executable file
8
app/views/common/_input_form_desc_field.html.haml
Executable 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}]"}
|
||||
|
5
app/views/common/_input_form_field.html.haml
Executable file
5
app/views/common/_input_form_field.html.haml
Executable 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}]"}
|
|
@ -15,7 +15,6 @@
|
|||
%a{:href=>"/"}
|
||||
= image_tag "logo.png"
|
||||
.row
|
||||
%hr/
|
||||
- if flash[:error]
|
||||
.alert.alert-error
|
||||
= flash[:error]
|
||||
|
|
|
@ -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"}
|
||||
%fieldset
|
||||
.control-group
|
||||
%label{:class=>"control-label",:for=>"login"}
|
||||
= User.human_attribute_name('login')
|
||||
.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)
|
||||
= render :partial => "common/input_form_field",:locals => { :model => 'user',:attr => 'login'}
|
||||
= render :partial => "common/input_form_field",:locals => { :model => 'user',:attr => 'password'}
|
||||
= render :partial => "common/form_button",:locals => { :text => t(:please_login,:scope=>:user)}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
9
app/views/user/setup.html.haml
Executable 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]}
|
Loading…
Reference in a new issue