优化密码设置流程

This commit is contained in:
guange 2018-11-23 16:41:52 +08:00
parent f007f5f249
commit a9b8d82da6
3 changed files with 33 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -27,6 +27,12 @@
<% end %>
<ul class="setting_left">
<li><span style="color:red;">*</span>&nbsp;&nbsp;登录名&nbsp;:&nbsp;</li>
<% if @is_oauth && !@is_set_password %>
<li>新密码&nbsp;:&nbsp;</li>
<li>确认密码&nbsp;:&nbsp;</li>
<% end %>
<li><span style="color:red;">*</span>&nbsp;&nbsp;邮箱&nbsp;:&nbsp;</li>
<li><span style="color:red;">*</span>&nbsp;&nbsp;职业&nbsp;:&nbsp;</li>
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" ><span style="color:red;">*</span>&nbsp;&nbsp;姓名&nbsp;:&nbsp;</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 %>