优化密码设置流程
This commit is contained in:
parent
f007f5f249
commit
a9b8d82da6
|
@ -147,13 +147,21 @@ class MyController < ApplicationController
|
|||
end
|
||||
|
||||
# 基本资料不完善 @force为false, 完善 @force为true
|
||||
@force = false
|
||||
@force = false
|
||||
if params[:tip]
|
||||
@force = true
|
||||
end
|
||||
|
||||
@user = User.current
|
||||
|
||||
#是否是oauth过来的
|
||||
@is_oauth = !!Oauth.find_by_user_id(@user.id)
|
||||
|
||||
#是否没设置过密码
|
||||
@is_set_password = @user.hashed_password.present?
|
||||
|
||||
|
||||
|
||||
lg = @user.login
|
||||
@pref = @user.pref
|
||||
diskfile = disk_filename('User', @user.id)
|
||||
|
@ -168,6 +176,16 @@ class MyController < ApplicationController
|
|||
@user.pref.attributes = params[:pref]
|
||||
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
|
||||
@user.login = params[:login].strip
|
||||
|
||||
if @is_oauth && !@user.mail.present?
|
||||
@user.mail = params[:user][:mail]
|
||||
end
|
||||
|
||||
if @is_oauth && !@is_set_password
|
||||
@user.password = params[:new_password]
|
||||
@user.password_confirmation = params[:new_password_confirmation]
|
||||
end
|
||||
|
||||
unless @user.user_extensions.nil?
|
||||
# 如果用户是从业者,将单位名称保存至学校id字段
|
||||
if @user.user_extensions.identity == 3
|
||||
|
|
|
@ -48,9 +48,9 @@ class OschinaController < ApplicationController
|
|||
|
||||
user = UserExtensions.where(:user_id => User.current.id).first
|
||||
if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil?
|
||||
redirect_to my_account_path(:tip => 1)
|
||||
redirect_to my_account_path
|
||||
elsif user.identity == 3 && user.school_id.nil?
|
||||
redirect_to my_account_path(:tip => 1)
|
||||
redirect_to my_account_path
|
||||
else
|
||||
redirect_to User.current
|
||||
end
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
<% end %>
|
||||
<ul class="setting_left">
|
||||
<li><span style="color:red;">*</span> 登录名 : </li>
|
||||
|
||||
<% if @is_oauth && !@is_set_password %>
|
||||
<li>新密码 : </li>
|
||||
<li>确认密码 : </li>
|
||||
<% end %>
|
||||
|
||||
<li><span style="color:red;">*</span> 邮箱 : </li>
|
||||
<li><span style="color:red;">*</span> 职业 : </li>
|
||||
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" ><span style="color:red;">*</span> 姓名 : </li>
|
||||
|
@ -50,6 +56,12 @@
|
|||
:class => "w210"
|
||||
%>
|
||||
</li>
|
||||
|
||||
<% if @is_oauth && !@is_set_password %>
|
||||
<li><input id="new_password" name="new_password" class="w210" type="password" required="true" nh_required="1"><span class="c_red ml5">请输入8-12个字符</span></li>
|
||||
<li><input id="new_password_confirmation" name="new_password_confirmation" class="w210" type="password" required="true" nh_required="1"></li>
|
||||
<% end %>
|
||||
|
||||
<% if @force %>
|
||||
<li><%= f.text_field :mail,:no_label=>true, :required => true,:nh_required => "1",:class=>"w210",:disabled=>'disabled'%></li>
|
||||
<% else %>
|
||||
|
|
Loading…
Reference in New Issue