添加邮箱验证功能

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2014-11-11 17:01:07 +08:00
parent 421d47a687
commit 2cea3178d6
3 changed files with 86 additions and 19 deletions

View File

@ -103,7 +103,7 @@ class AccountController < ApplicationController
def register
# @root_path="/home/pdl/redmine-2.3.2-0/apache2/"
#
@cache_identityy = params[:identity]||"" #身份
#@cache_identityy = params[:identity]||"" #身份
@cache_no = params[:no]||"" #学号
@cache_technical_title = params[:technical_title]||"" #教师职称
@cache_province = params[:province]||"" #省份
@ -136,7 +136,7 @@ class AccountController < ApplicationController
session[:auth_source_registration] = nil
self.logged_user = @user
flash[:notice] = l(:notice_account_activated)
redirect_to my_account_url
render :action => 'email_valid'
end
else
@user.login = params[:user][:login]
@ -144,22 +144,7 @@ class AccountController < ApplicationController
@user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation]
end
if(@cache_identityy == "")
if params[:identity] == "2"
@user.firstname = firstname_code
@user.lastname = lastname_code
end
flash.now[:error]= l(:label_identity)+l(:'activerecord.errors.messages.empty')
return
end
if(@cache_city == "")
if params[:identity] == "2"
@user.firstname = firstname_code
@user.lastname = lastname_code
end
flash.now[:error]= l(:label_location)+l(:'activerecord.errors.messages.empty')
return
end
case Setting.self_registration
when '1'
@ -234,6 +219,9 @@ class AccountController < ApplicationController
render :json => req
end
def email_valid
end
private
def authenticate_user
@ -363,7 +351,7 @@ class AccountController < ApplicationController
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
Mailer.register(token).deliver
flash[:notice] = l(:notice_account_register_done)
redirect_to signin_url
render action: 'email_valid'
else
yield if block_given?
end

View File

@ -0,0 +1,78 @@
<head>
<meta charset="utf-8">
<title>注册帐号</title>
<style type="text/css">
.register-info {
background: #fff;
border: 1px solid #ddd;
padding: 16px 7px 59px 16px;
margin-top: 57px;
overflow: hidden;
text-align: center;
}
.register-info .cancel,
.register-info .continue {
display: inline-block;
zoom: 1;
*display: inline;
width: 81px;
height: 30px;
line-height: 30px;
color: #fff;
}
.register-info .cancel {
background: #999;
margin-right: 60px;
}
.register-info .continue {
background: #dc3c00;
}
.register-info h3 {
font-size: 1.166em;
font-weight: normal;
border-bottom: 1px solid #ddd;
padding-bottom: 12px;
margin: 0;
text-align: left;
}
.register-info h3 .icon {
display: inline-block;
margin-right: 10px;
width: 16px;
height: 16px;
vertical-align: middle;
}
</style>
</head>
<body>
<% email = params[:mail] %>
<div class="register-info">
<h3><span class="icon"></span>邮箱激活</h3>
<div class="activation-email"><span class="icon-success-lg"></span>
<div class="content">
<h4>请在24小时内点击邮件中的链接继续完成注册</h4>
<div class="to-email">
<span class="summary">邮件已发送到邮箱</span>
<a href="#" class="f-blue">alanlong9278@126.com</a>
</div>
<span class="tracking-ad" data-mod="popu_29">
<% mail = "mail." + mail.split('@')[1] %>
<a href="http://<%= mail %>" class="btn-primary check-mail" target="_blank">立即查收邮件</a>
</span>
<span class="tracking-ad" data-mod="popu_30">
<a href="javascript:void(0);" class="f-blue no-email">没收到邮件?</a>
</span>
<div class="reSent-email"><span class="icon"></span>
<div class="cont">
<span>请先检查是否在垃圾邮件中</span>
<span class="tracking-ad" data-mod="popu_31">如果还未收到,
<a href="/account/register?action=resendActiveEmail&username=alanalan123456" class="reSent">重新发送邮件</a>
</span>
</div>
</div>
</div>
</div>
</div>
</body>

View File

@ -200,6 +200,7 @@ RedmineApp::Application.routes.draw do
match 'account/lost_password', :via => [:get, :post], :as => 'lost_password'
match 'account/activate', :via => :get
match 'account/valid_ajax', :via => :get
get 'account/email_valid', :to => 'account#email_valid'
match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post
match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post]