还原《注册》

Signed-off-by: alan <547533434@qq.com>
course_group v20141123_03
alan 11 years ago
parent 949867c50b
commit 6963d494ae

@ -66,7 +66,7 @@ class AccountController < ApplicationController
if @user.save
@token.destroy
flash[:notice] = l(:notice_account_password_updated)
redirect_to signin_url
redirect_to signin_path
return
end
end
@ -92,7 +92,7 @@ class AccountController < ApplicationController
Mailer.lost_password(token).deliver
end
flash[:notice] = l(:notice_account_lost_email_sent)
redirect_to signin_url
redirect_to signin_path
return
end
end
@ -103,7 +103,7 @@ class AccountController < ApplicationController
def register
# @root_path="/home/pdl/redmine-2.3.2-0/apache2/"
#
#@cache_identityy = params[:identity]||"" #身份
@cache_identityy = params[:identity]||"" #身份
@cache_no = params[:no]||"" #学号
@cache_technical_title = params[:technical_title]||"" #教师职称
@cache_province = params[:province]||"" #省份
@ -144,7 +144,22 @@ class AccountController < ApplicationController
@user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation]
end
if(@cache_identityy == "")
if params[:identity] == "2"
@user.firstname = firstname_code
@user.lastname = lastname_code
end
flash.now[:error]= l(:label_identity)+l(:'activerecord.errors.messages.empty')
return
end
if(@cache_city == "")
if params[:identity] == "2"
@user.firstname = firstname_code
@user.lastname = lastname_code
end
flash.now[:error]= l(:label_location)+l(:'activerecord.errors.messages.empty')
return
end
case Setting.self_registration
when '1'
@ -189,7 +204,7 @@ class AccountController < ApplicationController
token.destroy
flash[:notice] = l(:notice_account_activated)
end
redirect_to signin_url
redirect_to signin_path
end
def valid_ajax
@ -219,10 +234,6 @@ class AccountController < ApplicationController
render :json => req
end
def email_valid
end
private
def authenticate_user
@ -234,7 +245,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 +255,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 +302,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
@ -304,18 +315,13 @@ class AccountController < ApplicationController
code = /\d*/
#根据home_url生产正则表达式
eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/")
if code=~params[:back_url] && last_login_on != ''
if code=~params[:back_url]
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
redirect_back_or_default User.current
#redirect_to my_account_url
#redirect_to User.current
end
end
end
@ -357,7 +363,7 @@ class AccountController < ApplicationController
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
Mailer.register(token).deliver
flash[:notice] = l(:notice_account_register_done)
render action: 'email_valid', locals: {:mail => user.mail}
redirect_to signin_path
else
yield if block_given?
end
@ -374,7 +380,7 @@ class AccountController < ApplicationController
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
self.logged_user = user
flash[:notice] = l(:notice_account_activated)
redirect_to my_account_url
redirect_to my_account_path
else
yield if block_given?
end
@ -396,6 +402,6 @@ class AccountController < ApplicationController
def account_pending
flash[:notice] = l(:notice_account_pending)
redirect_to signin_url
redirect_to signin_path
end
end

@ -75,7 +75,6 @@ class User < Principal
has_many :homework_users
has_many :homework_attaches, :through => :homework_users
has_many :homework_evaluations
has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)},
:after_remove => Proc.new {|user, group| group.user_removed(user)}
@ -168,7 +167,7 @@ class User < Principal
LOGIN_LENGTH_LIMIT = 25
MAIL_LENGTH_LIMIT = 60
validates_presence_of :login, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
validates_presence_of :login, :firstname, :mail, :if => Proc.new { |user| !user.is_a?(AnonymousUser) }
validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, :case_sensitive => false
validates_uniqueness_of :mail, :if => Proc.new { |user| user.mail_changed? && user.mail.present? }, :case_sensitive => false
# Login must contain letters, numbers, underscores only
@ -199,19 +198,13 @@ class User < Principal
}
scope :sorted, lambda { order(*User.fields_for_order_statement)}
scope :like, lambda {|arg, type|
scope :like, lambda {|arg|
if arg.blank?
where(nil)
else
pattern = "%#{arg.to_s.strip.downcase}%"
#where(" LOWER(concat(lastname, firstname)) LIKE :p ", :p => pattern)
if type == "0"
where(" LOWER(login) LIKE :p ", :p => pattern)
elsif type == "1"
where(" LOWER(concat(lastname, firstname)) LIKE :p ", :p => pattern)
else
where(" LOWER(mail) LIKE :p ", :p => pattern)
end
where(" LOWER(login) LIKE :p ", :p => pattern)
end
}
@ -230,12 +223,7 @@ class User < Principal
#选择项目成员时显示的用户信息文字
def userInfo
if self.realname.gsub(' ','') == "" || self.realname.nil?
info = self.nickname;
else
info=self.nickname + ' (' + self.realname + ')';
end
info
info=self.nickname + ' (' + self.realname + ')';
end
###添加留言 fq
@ -364,11 +352,8 @@ class User < Principal
end
end
end
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, last_login_on]
user.update_column(:last_login_on, Time.now) if user && !user.new_record?
user
rescue => text
raise text
end

@ -20,20 +20,13 @@
}
}
</script>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />
</head>
<div id="login-form">
<%= form_tag(signin_path) do %>
<%= back_url_hidden_field_tag %>
<table>
<tr>
<td align="right">
<label for="username">
<%=l(:lable_user_name)%>:
</label>
</td>
<td align="right"><label for="username"><%=l(:lable_user_name)%>:</label></td>
<td align="left">
<%= text_field_tag 'username', params[:username], :tabindex => '1' , :value => "#{l(:label_login_prompt)}",
:onfocus => "clearInfo('username','#{l(:label_login_prompt)}')",
@ -42,48 +35,33 @@
</td>
</tr>
<tr>
<td align="right">
<label for="password">
<%=l(:field_password)%>:
</label>
</td>
<td align="left">
<%= password_field_tag 'password', nil, :tabindex => '2' %>
</td>
<td align="right"><label for="password"><%=l(:field_password)%>:</label></td>
<td align="left"><%= password_field_tag 'password', nil, :tabindex => '2' %></td>
</tr>
<% if Setting.openid? %>
<tr>
<td align="right">
<label for="openid_url">
<%=l(:field_identity_url)%>
</label>
</td>
<td align="left">
<%= text_field_tag "openid_url", nil, :tabindex => '3' %>
</td>
<td align="right"><label for="openid_url"><%=l(:field_identity_url)%></label></td>
<td align="left"><%= text_field_tag "openid_url", nil, :tabindex => '3' %></td>
</tr>
<% end %>
<tr>
<td></td>
<td align="left">
<% if Setting.autologin? %>
<label for="autologin">
<%= check_box_tag 'autologin', 1, false, :tabindex => 4 %>
<%= l(:label_stay_logged_in) %>
</label>
<label for="autologin"><%= check_box_tag 'autologin', 1, false, :tabindex => 4 %> <%= l(:label_stay_logged_in) %></label>
<% end %>
</td>
</tr>
<tr>
<td colspan="2" >
<span style="float: left">
<% if Setting.lost_password? %>
<span style="float: left"><% if Setting.lost_password? %>
<%= link_to l(:label_password_lost), lost_password_path %>
<% end %></span>
<span style="float: right">
<input type="submit" class="small" name="login" value="<%=l(:button_login)%> &#187;" tabindex="5"/></span>
</td>
</tr>
</table>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save