diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index cdbcc36cb..217c47866 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -357,13 +357,26 @@ class ProjectsController < ApplicationController end + # 项目邀请用户加入实现过程 # 两种情况:1、系统外用户;2、系统内用户 (通过邮件判定) def send_mail_to_member # 该邮箱未注册过 if !params[:mail].blank? && User.find_by_mail(params[:mail].to_s).nil? if !User.where("login =?", params[:mail]).first.nil? - # 用户名唯一,如果该邮箱被用户作为用户名使用则跳出 - flash[:error] = l(:notice_email_login_used) + # 用户名唯一,用户修改邮箱,未修改用户名,用户名等同邮箱的情况,默认改用户已经注册 + user = User.find_by_login(params[:mail].to_s) + if !user.member_of?(@project) + # 如果已经邀请过该用户,则不重复发送 + if InviteList.where("project_id =? and mail =?", @project.id, params[:mail].to_s).first.nil? + email = params[:mail] + Mailer.request_member_to_project(email, @project, User.current).deliver + flash[:notice] = l(:notice_email_sent, :value => email) + else + flash[:error] = l(:notice_email_invited) + end + else + flash[:error] = l(:label_member_of_project, :value => email) + end else email = params[:mail] Mailer.send_invite_in_project(email, @project, User.current).deliver @@ -393,7 +406,7 @@ class ProjectsController < ApplicationController end end - #发送邮件邀请新用户 + # 发送邮件邀请新用户页面对应方法 def invite_members_by_mail if User.current.member_of?(@project) || User.current.admin? @inviter_lists = InviteList.where(project_id:@project.id).all @@ -461,9 +474,9 @@ class ProjectsController < ApplicationController flash[:notice] = l(:label_mail_invite_success) end end + # 私有项目非项目成员无法访问成员列表 unless @project.is_public? return render_403 unless User.current.member_of?(@project) - end ## 有角色参数的才是课程,没有的就是项目 @render_file = 'project_member_list' diff --git a/app/views/mailer/request_member_to_project.html.erb b/app/views/mailer/request_member_to_project.html.erb index 7c0d25dbb..c2da231a3 100644 --- a/app/views/mailer/request_member_to_project.html.erb +++ b/app/views/mailer/request_member_to_project.html.erb @@ -4,9 +4,9 @@
<%= @invitor_name %> 邀请您加入项目:<%= @project_name %>
+<%= @invitor_name %> 邀请您加入项目:<%=link_to @project_name, project_url(@project) %>
-点击“同意加入”按钮,即可快速加入项目!
点击“同意加入”按钮,即可快速加入项目,查看项目相关信息!
<%= link_to @project_url, @project_url%>
您的账号为:<%= @email %>
密码为: <%= @password %>
+为了您的账号安全,请勿将邮件信息告知他人!