From f7db0a73809a340d9f700028a09029840beb15df Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 15 Jul 2019 18:07:39 +0800 Subject: [PATCH] =?UTF-8?q?git=20=E6=9B=B4=E6=96=B0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E5=A6=82=E6=9E=9C=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 4 ++-- app/helpers/application_helper.rb | 3 ++- app/models/user.rb | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 0df82118d..31395def2 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -267,7 +267,7 @@ class MyshixunsController < ApplicationController @content_modified = 1 author_name = current_user.real_name - author_email = current_user.mail + author_email = current_user.git_mail message = params[:evaluate] == 0 ? "System automatically submitted" : "User submitted" uid_logger("112233#{author_name}") uid_logger("112233#{author_email}") @@ -276,7 +276,7 @@ class MyshixunsController < ApplicationController message: message, content: content, author_name: author_name, - author_email: "author_email@email.com") + author_email: author_email) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index cdd647ebd..993c132dc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -30,8 +30,9 @@ module ApplicationHelper end # git用户 + # git用户命名规则:login+"@educoder.net" def git_username(email) - User.find_by_mail(email) + User.find_by_mail(email) || User.find_by_login(mail.split("@").first) end # 不同的类型扩展不同的目录 diff --git a/app/models/user.rb b/app/models/user.rb index 26f0fa544..89918551e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -156,6 +156,9 @@ class User < ApplicationRecord Token.where(:user_id => id, :action => 'session', :value => value).delete_all end + def git_mail + mail || "#{login}@educoder.net" + end # 学号 def student_id