From 295921c89d59db6dbde56930a9cc4e099f4f2fb1 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 15 Sep 2015 10:50:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E4=BB=B6=EF=BC=9A=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E6=96=B0=E7=94=A8=E6=88=B7=E7=9A=84=E6=97=B6=E5=80=99=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E6=8E=89=E9=82=AE=E7=AE=B1=E5=92=8C=E5=B7=B2=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E7=94=A8=E6=88=B7=E5=90=8D=E9=87=8D=E5=8F=A0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 7 ++++++- app/models/mailer.rb | 2 +- config/locales/zh.yml | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ae80f8fcb..1a8f6a7e2 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -359,11 +359,16 @@ class ProjectsController < ApplicationController # 两种情况:1、系统外用户;2、系统内用户 (通过邮件判定) def send_mail_to_member - if !params[:mail].blank? && User.find_by_mail(params[:mail].to_s).nil? + # 该邮箱未注册过 + if !params[:mail].blank? && User.find_by_mail(params[:mail].to_s).nil? && User.where("login =?", params[:mail]).first.nil? email = params[:mail] Mailer.run.send_invite_in_project(email, @project, User.current) @is_zhuce = false flash[:notice] = l(:notice_email_sent, :value => email) + # 用户名唯一,如果该邮箱被用户作为用户名使用则跳出 + elsif !User.where("login =?", params[:mail]).first.nil? + flash[:error] = l(:notice_email_login_used) + # 已经是系统注册用户 elsif !User.find_by_mail(params[:mail].to_s).nil? user = User.find_by_mail(params[:mail].to_s) if !user.member_of?(@project) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 4fe2478d2..37a4c9714 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -48,7 +48,7 @@ class Mailer < ActionMailer::Base end # author: alan - # 发送邀请未注册用户加入项目邮件 + # 邀请未注册用户加入项目 # 功能: 在加入项目的同时自动注册用户 def send_invite_in_project(email, project, invitor) @email = email diff --git a/config/locales/zh.yml b/config/locales/zh.yml index d2fa502b9..3c7aed5b3 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -52,6 +52,7 @@ zh: notice_not_authorized_archived_project: 要访问的项目已经归档。 notice_not_authorized_message: 您访问的消息不存在! notice_email_sent: "邮件已发送至 %{value}" + notice_email_login_used: 该邮箱地址已经有人作为登录名使用! notice_email_error: "发送邮件时发生错误 (%{value})" notice_feeds_access_key_reseted: 您的RSS存取键已被重置。 notice_api_access_key_reseted: 您的API访问键已被重置。