优化邮件邀请新用户、已注册用户

This commit is contained in:
huang 2015-05-22 10:15:57 +08:00
parent 4cef831c3a
commit a3fd541119
3 changed files with 17 additions and 9 deletions

View File

@ -247,9 +247,9 @@ class ProjectsController < ApplicationController
# 1、自动注册
# 2、加入项目、创建角色
# 3、用户得分
if params[:email]
user = User.find_by_mail(params[:email].to_s)
Member.create(:role_ids => [4], :user_id => user.id,:project_id => @project.id)
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])
end
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
return

View File

@ -47,6 +47,18 @@ module AccountHelper
user
end
# 自动创建一个新用户,但是初始状态是锁定的
def automatically_register_lock(user, &block)
user.lock
user.last_login_on = Time.now
if user.save
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
else
yield if block_given?
end
user
end
def administrator_manually__register(user, &block)
if user.save
UserStatus.create(:user_id => user.id ,:changsets_count => 0, :watchers_count => 0)

View File

@ -58,14 +58,10 @@ class Mailer < ActionMailer::Base
us = UsersService.new
# 自动激活用户
user = us.register_auto(login, @email, @password)
Member.create(:role_ids => [4], :user_id => user.id,:project_id => project.id)
UserGrade.create(:user_id => user.id, :project_id => project.id)
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, :token => @token.value
)
@project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value)
mail :to => email, :subject => @subject
end
@ -77,7 +73,7 @@ class Mailer < ActionMailer::Base
@project_name = "#{project.name}"
@user = user
@token = Token.get_token_from_user(user, 'autologin')
@project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :email => email, :token => @token.value)
@project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value)
mail :to => email, :subject => @subject
end