From d9ae9c80614943f4983a8c06f38000cdf5cbf4a1 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 May 2015 14:36:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=82=AE=E4=BB=B6=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=8F=90=E9=86=92=EF=BC=88=E9=82=80=E8=AF=B7=EF=BC=9A?= =?UTF-8?q?=E6=9C=AA=E6=BF=80=E6=B4=BB=20=E7=82=B9=E5=87=BB=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=EF=BC=9A=E6=BF=80=E6=B4=BB=E5=B9=B6=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 16 ++++++++++++++-- app/models/mailer.rb | 4 ++-- config/locales/projects/zh.yml | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b9e46daee..b8764cc48 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -248,8 +248,20 @@ class ProjectsController < ApplicationController # 2、加入项目、创建角色 # 3、用户得分 if params[:mail] - Member.create(:role_ids => [4], :user_id => params[:user],:project_id => params[:id]) - UserGrade.create(:user_id =>params[:user], :project_id => params[:id]) + user = User.find(params[:user_id]) + user.activate! + Member.create(:role_ids => [4], :user_id => params[:user_id],:project_id => params[:id]) + UserGrade.create(:user_id => params[:user_id], :project_id => params[:id]) + token = Token.get_token_from_user(user, 'autologin') + #user = User.try_to_autologin(token.value) + if user + start_user_session(user) + user.save + redirect_to project_member_path(params[:id]) + return + # account_ project_member_path(params[:id]) + flash[:notice] = l(:label_mail_invite_success) + end end if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 2c3a94874..4018f44a9 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -60,8 +60,8 @@ class Mailer < ActionMailer::Base user = us.register_auto(login, @email, @password) User.current = user unless User.current.nil? @user = user - @token = Token.get_token_from_user(user, 'autologin') - @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value) + + @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user_id => user.id, :mail => true) mail :to => email, :subject => @subject end diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 180b0322a..8ca078084 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -342,6 +342,7 @@ zh: label_invite_trustie_user_tips: "输入姓名、邮箱、昵称" label_user_role_null: 用户和角色不能留空! label_invite_project: 邀请您加入项目 + label_mail_invite_success: 您已成功加入项目! label_invite_success: 邀请成功 label_invite_members: 邀请用户 #