-
+
+
From 3417b2bce198677f3e303b358d275ba9ffe95571 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Sat, 22 Nov 2014 22:50:48 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E3=80=8A=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=B7=B3=E8=BD=AC=E3=80=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: alan <547533434@qq.com> --- app/controllers/account_controller.rb | 30 ++++++++++++--------------- app/models/user.rb | 8 +++---- app/views/account/login.html.erb | 5 ++++- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index b5975e452..aedfc7407 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -234,7 +234,7 @@ class AccountController < ApplicationController end def password_authentication - user, last_login_on = User.try_to_login(params[:username], params[:password]) + user = User.try_to_login(params[:username], params[:password]) if user.nil? invalid_credentials @@ -244,7 +244,7 @@ class AccountController < ApplicationController onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id }) else # Valid user - successful_authentication(user, last_login_on) + successful_authentication(user) end end @@ -291,7 +291,7 @@ class AccountController < ApplicationController end end - def successful_authentication(user, last_login_on) + def successful_authentication(user) logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}" # Valid user self.logged_user = user @@ -302,20 +302,16 @@ class AccountController < ApplicationController call_hook(:controller_account_success_authentication_after, {:user => user }) code = /\d*/ - #根据home_url生产正则表达式 - eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") - if code=~params[:back_url] && last_login_on != '' - redirect_to user_activities_path(user) - else - if last_login_on == '' - redirect_to my_account_url - else - #by young - #redirect_back_or_default my_page_path - #sredirect_back_or_default User.current - redirect_to my_account_url - #redirect_to User.current - end + #根据home_url生产正则表达式 + eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") + if code=~params[:back_url] + redirect_to user_activities_path(user) + else + + #by young + #redirect_back_or_default my_page_path + redirect_back_or_default User.current + end end diff --git a/app/models/user.rb b/app/models/user.rb index 48254ef90..8e6f121b0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -364,11 +364,11 @@ class User < Principal end end end - unless user.nil? - last_login_on = user.last_login_on.nil? ? '' : user.last_login_on.to_s + if user && !user.new_record? + #last_login_on = user.last_login_on.nil? ? '' : user.last_login_on.to_s + user.update_column(:last_login_on, Time.now) end - user.update_column(:last_login_on, Time.now) if user && !user.new_record? - [user, last_login_on] + user rescue => text raise text end diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 1115ca80e..4175282b3 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -20,7 +20,10 @@ } } - +
+ + +- - | +<%= text_field_tag 'username', params[:username], :tabindex => '1' , :value => "#{l(:label_login_prompt)}", :onfocus => "clearInfo('username','#{l(:label_login_prompt)}')", @@ -42,48 +35,33 @@ | ||
- - | -- <%= password_field_tag 'password', nil, :tabindex => '2' %> - | ++ | <%= password_field_tag 'password', nil, :tabindex => '2' %> |
- - | -- <%= text_field_tag "openid_url", nil, :tabindex => '3' %> - | ++ | <%= text_field_tag "openid_url", nil, :tabindex => '3' %> |
<% if Setting.autologin? %> - + <% end %> | |||
- - <% if Setting.lost_password? %> + <% if Setting.lost_password? %> <%= link_to l(:label_password_lost), lost_password_path %> <% end %> + |
<%= f.text_field :login, :size => 25, :required => true %> - <%= l(:label_max_number) %> -
-<%= f.password_field :password, :size => 25, :required => true %> - <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %> -
-<%= f.password_field :password_confirmation, :size => 25, :required => true %>
- <% end %> - -- <%= f.text_field :mail,:size => 25, :required => true %> - -
-
-
- <%= "#{l(:label_mail_attention)} " %> <%= "#{l(:label_mail_attention1)} " %>
-
<%= submit_tag l(:button_submit) %> | -
<%= f.text_field :identity_url %>
-<% end %> -<% @user.custom_field_values.select { |v| v.editable? || v.required? }.each do |value| %> -<%= custom_field_tag_with_label :user, value %>
-<% end %> -+
+ <%= l(:label_identity) %> * | ++ + | ++ | + + +<% else %> +<%= text_field_tag :no, nil, :placeholder => "请输入学号" %> +<% end %> +
<%= f.text_field :login, :size => 25, :required => true %> + <%= l(:label_max_number) %>
+ +<%= f.password_field :password, :size => 25, :required => true %> + <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>
+ +<%= f.password_field :password_confirmation, :size => 25, :required => true %>
+ <% end %> + + + +<%= f.text_field :mail, :required => true %>
+ ++ <%= "#{l(:label_mail_attention)} " %>
+ +<%= f.select :language, lang_options_for_select, :required => true %>
+ + + + + + ++
+ <%= l(:label_location) %> * + | ++ + | ++ + | +
+
<%= submit_tag l(:button_submit) %> | +
<%= f.text_field :identity_url %>
+<% end %> + + +<% @user.custom_field_values.select { |v| v.editable? || v.required? }.each do |value| %> +<%= custom_field_tag_with_label :user, value %>
+<% end %> +
+ <%= f.text_field :login, :required => true, :name => "login"%>
+ <%= l(:label_max_number) %>
+
+
+ <% if User.current.user_extensions.school.nil? %> + <%= l(:field_occupation) %> * + + + + <% else %> + <%= l(:field_occupation) %> * + + + + <% end %> +
+ ++ <%= f.text_field :mail, :required => true %> +
+ ++ <%= f.select :language, :Chinese => :zh, :English => :en %> +
+ + + + <% province = User.current.user_extensions.location %> + <% city = User.current.user_extensions.location_city %> + <% identity = User.current.user_extensions.identity %> + <% title = User.current.user_extensions.technical_title %> + + +<%= l(:label_location) %> + + +
+ + + + <% unless @user.user_extensions.identity == 2 %> ++ <%= l(:label_identity) %> + +
+ <% end %> + + + <% end %> + + + <% else %> + +<%= f.text_field :identity_url %>
+ <% end %> + + <% @user.custom_field_values.select(&:editable?).each do |value| %> +<%= custom_field_tag_with_label :user, value %>
+ <% end %> + <%= call_hook(:view_my_account, :user => @user, :form => f) %> ++ <%= render :partial => 'users/mail_notifications' %> +
+ | + + | <%= text_field_tag 'username', params[:username], :tabindex => '1' , :value => "#{l(:label_login_prompt)}", :onfocus => "clearInfo('username','#{l(:label_login_prompt)}')", @@ -35,33 +42,48 @@ | |
- | <%= password_field_tag 'password', nil, :tabindex => '2' %> | ++ + | ++ <%= password_field_tag 'password', nil, :tabindex => '2' %> + |
- | <%= text_field_tag "openid_url", nil, :tabindex => '3' %> | ++ + | ++ <%= text_field_tag "openid_url", nil, :tabindex => '3' %> + |
<% if Setting.autologin? %> - + <% end %> | |||
- <% if Setting.lost_password? %> + + <% if Setting.lost_password? %> <%= link_to l(:label_password_lost), lost_password_path %> <% end %> - |
-
- <%= l(:label_identity) %> * | -- - | -- | - - -<% else %> -<%= text_field_tag :no, nil, :placeholder => "请输入学号" %> -<% end %> -
<%= f.text_field :login, :size => 25, :required => true %> - <%= l(:label_max_number) %>
- -<%= f.password_field :password, :size => 25, :required => true %> - <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>
- -<%= f.password_field :password_confirmation, :size => 25, :required => true %>
- <% end %> - - - -<%= f.text_field :mail, :required => true %>
- -- <%= "#{l(:label_mail_attention)} " %>
- -<%= f.select :language, lang_options_for_select, :required => true %>
- - - - - - --
- <%= l(:label_location) %> * - | -- - | -- - | -
-
<%= submit_tag l(:button_submit) %> | -
<%= f.text_field :identity_url %>
-<% end %> - - -<% @user.custom_field_values.select { |v| v.editable? || v.required? }.each do |value| %> -<%= custom_field_tag_with_label :user, value %>
-<% end %> -
- <%= f.text_field :login, :required => true, :name => "login"%>
- <%= l(:label_max_number) %>
-
-
- <% if User.current.user_extensions.school.nil? %> - <%= l(:field_occupation) %> * - - - - <% else %> - <%= l(:field_occupation) %> * - - - - <% end %> -
- -- <%= f.text_field :mail, :required => true %> -
- -- <%= f.select :language, :Chinese => :zh, :English => :en %> -
- - - - <% province = User.current.user_extensions.location %> - <% city = User.current.user_extensions.location_city %> - <% identity = User.current.user_extensions.identity %> - <% title = User.current.user_extensions.technical_title %> - - -<%= l(:label_location) %> - - -
- - - - <% unless @user.user_extensions.identity == 2 %> -- <%= l(:label_identity) %> - -
- <% end %> - - - <% end %> - - - <% else %> - -<%= f.text_field :identity_url %>
- <% end %> - - <% @user.custom_field_values.select(&:editable?).each do |value| %> -<%= custom_field_tag_with_label :user, value %>
- <% end %> - <%= call_hook(:view_my_account, :user => @user, :form => f) %> -- <%= render :partial => 'users/mail_notifications' %> -
+ <%= f.text_field :login, :required => true, :size => 25, :name => "login", :readonly => true, :style => 'border:1px solid #d3d3d3;'%>
+ <%= l(:label_max_number) %>
+
+
+ + +
+ + + <% end %> + + + + + + + + + + + + + + + + + + ++ <%= f.text_field :mail, :required => true %> +
+ ++ <%= f.select :language, :Chinese => :zh, :English => :en %> +
+ + + <% if !User.current.user_extensions.nil? %> + <% province = User.current.user_extensions.location %> + <% city = User.current.user_extensions.location_city %> + <% identity = User.current.user_extensions.identity %> + <% occupation1 = User.current.user_extensions.occupation %> + <% occupation = User.current.user_extensions.occupation %> + <% title = User.current.user_extensions.technical_title %> + <% language = User.current.language %> + <% else %> + <% province = "湖南省" %> + <% city = "长沙"%> + <% identity = ""%> + <% occupation1 = ""%> + <% title = "" %> + <% language = ""%> + <% end %> + + ++ + +
+ + + + ++ <%= f.text_field :identity_url %> +
+ <% end %> + + <% @user.custom_field_values.select(&:editable?).each do |value| %> +<%= custom_field_tag_with_label :user, value %>
+ <% end %> + <%= call_hook(:view_my_account, :user => @user, :form => f) %> ++ <%= render :partial => 'users/mail_notifications' %> +