登陆界面

This commit is contained in:
lizanle 2015-08-25 14:24:20 +08:00
parent 5bf7aeb430
commit d25971f546
4 changed files with 268 additions and 218 deletions

View File

@ -27,8 +27,9 @@ class AccountController < ApplicationController
if request.get?
if User.current.logged?
redirect_to home_url
else
render :layout => 'login'
end
# render :layout => 'login'
else
authenticate_user
end
@ -129,10 +130,12 @@ class AccountController < ApplicationController
end
when '3'
#register_automatically(@user)
unless @user.new_record?
if !@user.new_record?
self.logged_user = @user
flash[:notice] = l(:notice_account_activated)
redirect_to my_account_url
else
redirect_to signin_path
end
else
#register_manually_by_administrator(@user)
@ -355,11 +358,13 @@ class AccountController < ApplicationController
def invalid_credentials
logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}"
flash.now[:error] = l(:notice_account_invalid_creditentials)
render :layout => 'login'
end
def invalid_credentials_new
logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}"
flash.now[:error] = l(:notice_account_invalid_creditentials_new)
render :layout => 'login'
end
# Register a user for email activation.

View File

@ -1,17 +1,49 @@
<% @nav_dispaly_home_path_label = 1
@nav_dispaly_main_course_label = 1
@nav_dispaly_main_project_label = 1
@nav_dispaly_main_contest_label = 1 %>
<% @nav_dispaly_forum_label = 1%>
<%= call_hook :view_account_login_top %>
<%= stylesheet_link_tag 'new_public'%>
<%= stylesheet_link_tag 'leftside'%>
<script type="text/javascript" language="javascript">
<script>
$(document).ready(function(){
$("#loginSignButton").click(function(){
$("#signUpBox").css({display:"block"});
$("#loginInBox").css({display:"none"});
});
$("#loginInButton").click(function(){
$("#signUpBox").css({display:"none"});
$("#loginInBox").css({display:"block"});
});
});
$(document).ready(function(){
$(".homepageSearchIcon").click(function(){
var val=$('input:radio[name="navSearchType"]:checked').val();
if(val==null){
$("#navSearchAlert").css({display:"block"});
}
else {
$("#navSearchAlert").css({display:"none"});
}
});
$("#loginInButton").click(function(){
$("#signUpBox").css({display:"none"});
$("#loginInBox").css({display:"block"});
});
});
$(document).ready(function(){
$(".navHomepageSearchBoxcontainer").mouseover(function(){
$(".navSearchTypeBox").css({display:"block"});
});
$(".navHomepageSearchBoxcontainer").mouseout(function(){
$(".navSearchTypeBox").css({display:"none"});
});
})
function clearInfo(id, content) {
var text = $('#' + id);
if (text.val() == content) {
$('#' + id).val('');
}
}
var text = $('#' + id);
if (text.val() == content) {
$('#' + id).val('');
}
}
function showInfo(id, content) {
var text = $('#' + id);
@ -19,80 +51,193 @@
$('#' + id).val(content);
}
}
</script>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />
</head>
<div id="login-form">
<%= form_tag(signin_path) do %>
<%= back_url_hidden_field_tag %>
<table>
<tr>
<td align="right">
<label for="username">
<%=l(:lable_user_name)%>:
</label>
</td>
<td align="left">
<%= text_field_tag 'username', params[:username], :tabindex => '1' , :value => "#{l(:label_login_prompt)}",
:onfocus => "clearInfo('username','#{l(:label_login_prompt)}')",
:onblur => "showInfo('username','#{l(:label_login_prompt)}')",
:style => "resize: none;font-size: 12px;color: #818283;"%>
</td>
</tr>
<tr>
<td align="right">
<label for="password">
<%=l(:field_password)%>:
</label>
</td>
<td align="left">
<%= password_field_tag 'password', nil, :tabindex => '2' %>
</td>
</tr>
<% if Setting.openid? %>
<tr>
<td align="right">
<label for="openid_url">
<%=l(:field_identity_url)%>
</label>
</td>
<td align="left">
<%= text_field_tag "openid_url", nil, :tabindex => '3' %>
</td>
</tr>
<% end %>
<tr>
<td></td>
<td align="left">
<% if Setting.autologin? %>
<label for="autologin">
<%= check_box_tag 'autologin', 1, true, :tabindex => 4 %>
<%= l(:label_stay_logged_in) %>
</label>
<% end %>
</td>
</tr>
<tr>
<td colspan="2" >
<span style="float: left">
<% if Setting.lost_password? %>
<%= link_to l(:label_password_lost), lost_password_path %>
<% end %></span>
<span style="float: right">
<input type="submit" class="small" name="login" value="<%=l(:button_login)%> &#187;" tabindex="5"/></span>
</td>
</tr>
</table>
<% end %>
</div>
<%= call_hook :view_account_login_bottom %>
<% if params[:username].present? %>
<%= javascript_tag "$('#password').focus();" %>
<% else %>
<%= javascript_tag "$('#username').focus();" %>
<% end %>
function login(){
$('#main_login_form').submit(); //表单提交没有任何反应的原因js冲突
}
function register(){
if($login_correct && $mail_correct && $passwd_correct && $passwd_comfirm_correct){
$("#main_reg_form").submit();
}else{
$('#user_login').blur();
$('#user_mail').blur();
$('#user_password').blur();
$('#user_password_confirmation').blur();
}
}
var $login_correct = false;
var $mail_correct = false;
var $passwd_correct = false;
var $passwd_comfirm_correct = false;
jQuery(document).ready(function () {
var $login = $('#user_login')
var $mail = $('#user_mail')
var $password = $('#user_password')
var $password_confirmation = $('#user_password_confirmation')
$login.blur(function (event) {
if ($(this).is('#user_login')) {
$.get(
'<%=account_valid_ajax_path%>',
{ valid: "login",
value: this.value },
function (data) {
if (data.valid) {
$('#login_req').html('<span style="color: green">'+data.message+'</span>');
$login_correct = true;
} else {
$('#login_req').html( '<span style="color: red">'+data.message+'</span>');
$login_correct = false;
}
$('#login_req').css('display','block');
});
}
;
});
$mail.blur(function (event) {
if ($(this).is('#user_mail')) {
$.get('<%=account_valid_ajax_path%>',
{ valid: "mail",
value: this.value },
function (data) {
if (data.valid) {
$('#mail_req').html( '<span style="color: green">'+data.message+'</span>' );
$mail_correct = true;
} else {
$('#mail_req').html( '<span style="color: red">'+data.message+'</span>' );
$mail_correct = false;
}
$('#mail_req').css('display','block');
});
}
;
});
$password.blur(function () {
var pas1 = document.getElementById("user_password").value;
var password_min_length = <%= Setting.password_min_length.to_i %>
if (pas1.length >= password_min_length) {
$('#passwd_req').html('');
$passwd_correct = true;
}
else {
$('#passwd_req').html( '<span style="color: red">'+'<%= l(:setting_password_min_length_limit, :count => Setting.password_min_length.to_i) %>'+'</span>');
$passwd_correct = false;
}
$('#passwd_req').css('display','block');
});
$password_confirmation.blur(function () {
var password_min_length = <%= Setting.password_min_length.to_i %>
var pas1 = document.getElementById("user_password").value;
var pas2 = document.getElementById("user_password_confirmation").value;
if (pas1.length >= password_min_length && pas1 == pas2 ) {
$('#confirm_req').html('<span style="color: green">'+'<%= l(:setting_password_success) %>'+'</span>');
$passwd_comfirm_correct = true;
}
else {
$('#confirm_req').html('<span style="color: red">'+'<%= l(:setting_password_error) %>'+'</span>');
$passwd_comfirm_correct = false;
}
$('#confirm_req').css('display','block');
});
});
</script>
<div class="loginContentContainer">
<div class="loginContent">
<div class="loginLeft">
<div class="loginLogo"><img src="images/trustie_big_log.png" width="100" height="88" alt="Trustie Logo" /></div>
<div class="loginInro">欢迎加入Trustie高校创新实践社区老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。Trustie是在中国推行大规模开放在线研究模式MOORE的支撑平台。</div>
</div>
<div class="loginRight">
<div id="loginInBox">
<div class="loginChooseBox">
<ul class="loginChooseList">
<li class="loginChoose fl"><span class="loginChooseTab">登陆</span></li>
<li class="loginChooseBorder fl"></li>
</ul>
</div>
<div class="loginIn">
<%= form_tag(signin_path,:id=>'main_login_form',:method=>'post') do %>
<%= back_url_hidden_field_tag %>
<div class="mb20">
<%= text_field_tag 'username', params[:username], :tabindex => '1' ,
:class=>'loginSignBox',:placeholder=>'请输入邮箱地址或昵称'%>
<!--<input type="text" placeholder="请输入邮箱地址或昵称" class="loginSignBox" />-->
</div>
<% if Setting.openid? %>
<div class="mb20">
<%= text_field_tag "openid_url", nil, :tabindex => '3',:placeholder=>'请输入OpenId URL' %>
</div>
<% end %>
<div>
<!--<input type="text" placeholder="请输密码" class="loginSignBox" />-->
<%= password_field_tag 'password', nil, :tabindex => '2',:class=>'loginSignBox' ,:placeholder=>'请输密码'%>
</div>
<div class="loginSignOption">
<% if Setting.autologin? %>
<div class="fl mt3 mr5">
<%= check_box_tag 'autologin', 1, true, :tabindex => 4 %>
</div>
<%= l(:label_stay_logged_in) %>
<% end %>
<a href="<%= lost_password_path %>" class="newsBlue mr40 fr">
<% if Setting.lost_password? %>
<u>忘记密码?</u>
<% end %>
</a></div>
<% end %>
<div class="loginInButton" >
<a href="javascript:void(0);" class="c_white db" onclick="login();">登陆</a>
</div>
</div>
</div>
<div id="signUpBox">
<div class="loginChooseBox">
<ul class="loginChooseList">
<li class="loginChoose fl"><span class="loginChooseTab">注册<%= link_to l(:label_login_with_open_id_option), signin_url if Setting.openid? %></a></span>
<li class="loginChooseBorder fl"></li>
</ul>
</div>
<div class="loginIn">
<%= form_for :user, :url => register_path,:method=>'post',:html=>{:id=>'main_reg_form'} do |f| %>
<%= error_messages_for 'user' %>
<div class="loginSignRow">
<!--<input type="text" placeholder="请输入邮箱地址" class="loginSignBox" />-->
<%= f.text_field :mail,:size => 25, :class=>'loginSignBox' ,:placeholder=>"请输入邮箱地址"%>
<div class="loginSignAlert" id="mail_req" style="display: none" >请输入有效邮箱地址</div>
</div>
<div class="loginSignRow">
<!--<input type="text" placeholder="请输入密码" class="loginSignBox" />-->
<%= f.password_field :password, :size => 25,:placeholder=>"请输入密码",:class=>'loginSignBox' %>
<div class="loginSignAlert" id="passwd_req" style="display: none">至少需要 6 个字符</div>
</div>
<div class="loginSignRow">
<!--<input type="text" placeholder="请再次输入密码" class="loginSignBox" />-->
<%= f.password_field :password_confirmation, :size => 25,:placeholder=>"请再次输入密码",:class=>'loginSignBox' %>
<div class="loginSignAlert" id="confirm_req" style="display: none">密码不一致</div>
</div>
<div class="loginSignRow">
<!--<input type="text" placeholder="请输入用户昵称" class="loginSignBox" />-->
<%= f.text_field :login, :size => 25,:placeholder=>"请输入用户昵称",:class=>'loginSignBox'%>
<div class="loginSignAlert" id="login_req" style="display: none">用户昵称为2-18个中英文数字或下划线</div>
</div>
<div class="loginUpButton">
<a href="javascript:void(0);" class="c_white db" onclick="register();">注册</a>
</div>
<% end %>
</div>
</div>
</div>
<div class="cl"></div>
</div>
</div>

View File

@ -1,131 +1,28 @@
<%= stylesheet_link_tag 'new_public'%>
<%= stylesheet_link_tag 'leftside'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title><%= h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'new_public', 'user_leftside', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag 'javascripts/jquery-1.3.2' %>
<%= javascript_include_tag 'bootstrap' %>
<script>
$(document).ready(function(){
$("#loginSignButton").click(function(){
$("#signUpBox").css({display:"block"});
$("#loginInBox").css({display:"none"});
});
$("#loginInButton").click(function(){
$("#signUpBox").css({display:"none"});
$("#loginInBox").css({display:"block"});
});
});
$(document).ready(function(){
$(".homepageSearchIcon").click(function(){
var val=$('input:radio[name="navSearchType"]:checked').val();
if(val==null){
$("#navSearchAlert").css({display:"block"});
}
else {
$("#navSearchAlert").css({display:"none"});
}
});
$("#loginInButton").click(function(){
$("#signUpBox").css({display:"none"});
$("#loginInBox").css({display:"block"});
});
});
$(document).ready(function(){
$(".navHomepageSearchBoxcontainer").mouseover(function(){
$(".navSearchTypeBox").css({display:"block"});
});
$(".navHomepageSearchBoxcontainer").mouseout(function(){
$(".navSearchTypeBox").css({display:"none"});
});
})
</script>
<%= javascript_include_tag "bootstrap","avatars","new_user"%>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= yield :header_tags -%>
</head>
<div class="navContainer">
<div class="navHomepage">
<div class="navHomepageLogo fl"><a href="javascript:void(0);"><img src="images/nav_logo.png" width="51" height="45" alt="确实Trustie" class="mt3" /></a></div>
<div class="fl">
<ul>
<li class="navHomepageMenu fl"><a href="javascript:void(0);" class="c_white f16">帮助中心</a></li>
</ul>
</div>
<div class="navHomepageSearchBoxcontainer fl">
<form class="navHomepageSearchBox">
<input type="text" name="navHomepageSearch" class="navHomepageSearchInput" />
<a href="javascript:void(0);" class="homepageSearchIcon"></a>
</form>
<div class="navSearchTypeBox">
<form class="mt8">
<div class="fl mr15"><div class="fl mt5"><input type="radio" value="课程" name="navSearchType" /></div>
课程</div>
<div class="fl mr15"><div class="fl mt5"><input type="radio" value="项目" name="navSearchType" /></div>
项目</div>
<div class="fl mr15"><div class="fl mt5"><input type="radio" value="用户" name="navSearchType" /></div>
用户</div>
<div id="navSearchAlert" class="fr mr10"><span class="c_red">请选择搜索类型</span></div>
</form>
</div>
</div>
<div id="loginInButton" class="fr ml20"><a href="javascript:void(0);" class="c_white db">登录</a></div>
<div id="loginSignButton" class="fr"><a href="javascript:void(0);" class="c_white db">注册</a></div>
</div>
</div>
<div class="loginContentContainer">
<div class="loginContent">
<div class="loginLeft">
<div class="loginLogo"><img src="images/trustie_big_log.png" width="100" height="88" alt="Trustie Logo" /></div>
<div class="loginInro">欢迎加入Trustie高校创新实践社区老师、学生和科研人员可以在此开展各种在线协同学习、协同作业、协同开发等活动。Trustie是在中国推行大规模开放在线研究模式MOORE的支撑平台。</div>
</div>
<div class="loginRight">
<div id="loginInBox">
<div class="loginChooseBox">
<ul class="loginChooseList">
<li class="loginChoose fl"><span class="loginChooseTab">登陆</span></li>
<li class="loginChooseBorder fl"></li>
</ul>
</div>
<div class="loginIn">
<div class="mb20">
<input type="text" placeholder="请输入邮箱地址或昵称" class="loginSignBox" />
</div>
<div>
<input type="text" placeholder="请输密码" class="loginSignBox" />
</div>
<div class="loginSignOption">
<div class="fl mt3 mr5">
<input type="checkbox" />
</div>
<a href="javascript:void(0);">自动登录</a><a href="javascript:void(0);" class="newsBlue mr40 fr"><u>忘记密码?</u></a></div>
<div class="loginInButton"><a href="javascript:void(0);" class="c_white db">登陆</a></div>
</div>
</div>
<div id="signUpBox">
<div class="loginChooseBox">
<ul class="loginChooseList">
<li class="loginChoose fl"><span class="loginChooseTab">注册</a></span>
<li class="loginChooseBorder fl"></li>
</ul>
</div>
<div class="loginIn">
<div>
<input type="text" placeholder="请输入邮箱地址" class="loginSignBox" />
<div class="loginSignAlert mb8">请输入有效邮箱地址</div>
</div>
<div>
<input type="text" placeholder="请输入密码" class="loginSignBox" />
<div class="loginSignAlert mb8">至少需要 6 个字符</div>
</div>
<div class="mb20">
<input type="text" placeholder="请再次输入密码" class="loginSignBox" />
</div>
<div>
<input type="text" placeholder="请输入用户昵称" class="loginSignBox" />
<div class="loginSignAlert mb8">用户昵称为2-18个中英文数字或下划线</div>
</div>
<div class="loginUpButton"><a href="javascript:void(0);" class="c_white db">注册</a></div>
</div>
</div>
</div>
<div class="cl"></div>
</div>
<% is_current_user = User.current.logged? && User.current == @user%>
<% if User.current.logged? %>
<%= render :partial => 'layouts/logined_header' %>
<% else%>
<%= render :partial => 'layouts/unlogin_header' %>
<% end%>
</div>
<%= render_flash_messages %>
<%= yield %>

View File

@ -124,6 +124,7 @@ a.c_blue{ color:#15bccf;}
a.c_dblue{ color:#09658c;}
a:hover.c_dblue{ color:#15bccf;}
a.c_white{ color:#fff;}
input.c_white { color:#fff}
a.c_dorange{ color:#fd6e2a;}
a.c_dark{color: #3e4040;}
a:hover.c_dark{color: #3ca5c6;}
@ -612,7 +613,9 @@ a.loginChooseTab {color:#484848; height:30px; display:block;}
.loginSignBox {width:308px; height:38px; margin-left:46px; border:1px solid #98a1a6; outline:none;}
.loginSignOption {margin-left:46px; margin-top:15px;}
.loginIn {width:405px; background-color:#ffffff; padding-bottom:30px;}
.loginSignAlert {font-size:12px; color:#fc0000; margin-left:60px;}
.loginSignAlert {font-size:12px; margin-left:60px;}
.loginSignRow {height:60px; min-height:60px;}