Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_ec
杨树明 5 years ago
commit f080304412

@ -657,7 +657,8 @@ class GamesController < ApplicationController
# 高性能取上一关、下一关
prev_game = @game.prev_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position)
next_game = @game.next_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) if had_passed
next_game = @game.next_game(@shixun.id, @game.myshixun_id, game_challenge.position) if had_passed
next_game.update_column(:status, 0) if next_game.present? && next_game.status == 3
# 高性能取上一关、下一关
#prev_game = Game.prev_identifier(@shixun.id, @game.myshixun_id, game_challenge.position)
@ -670,7 +671,7 @@ class GamesController < ApplicationController
choose_correct_num: choose_correct_num,
test_sets: test_sets,
prev_game: prev_game,
next_game: next_game}
next_game: next_game&.identifier}
rescue Exception => e
uid_logger("choose build failed #{e.message}")
@result = [status: -1, contents: "#{e.message}"]

@ -4,5 +4,12 @@ class Users::ApplyAuthenticationForm
attr_accessor :name, :id_number, :upload_image
validates :name, presence: true
validates :id_number, presence: true
validate :validate_ID_number
def validate_ID_number
unless id_number =~ User::VALID_NUMBER_REGEX
raise("身份证格式不对")
end
end
end

@ -20,6 +20,8 @@ class User < ApplicationRecord
VALID_EMAIL_REGEX = /^[a-zA-Z0-9]+([.\-_\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/i
VALID_PHONE_REGEX = /^1\d{10}$/
# 身份证
VALID_NUMBER_REGEX = /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
LOGIN_LENGTH_LIMIT = 30
MAIL_LENGTH_LMIT = 60
@ -162,7 +164,8 @@ class User < ApplicationRecord
# validates_format_of :mail, with: VALID_EMAIL_REGEX, multiline: true
# validates_format_of :phone, with: VALID_PHONE_REGEX, multiline: true
validate :validate_password_length
#validate :validate_ID_number
#validates_format_of :ID_number, with: VALID_NUMBER_REGEX, multiline: true, message: "身份证号格式不对"
# validates :nickname, presence: true, length: { maximum: 10 }
# validates :lastname, presence: true

@ -25,10 +25,10 @@ class Users::ApplyAuthenticationService < ApplicationService
user.apply_user_authentication.create!(auth_type: 1, status: 0)
move_image_file! unless params[:upload_image].to_s == 'false'
sms_notify_admin
end
sms_notify_admin
user
end

@ -37,13 +37,9 @@ class Users::ApplyProfessionalAuthService < ApplicationService
user.apply_user_authentication.create!(auth_type: 2, status: 0)
move_image_file! unless params[:upload_image].to_s == 'false'
sms_cache = Rails.cache.read("apply_pro_certification")
if sms_cache.nil?
sms_notify_admin
Rails.cache.write("apply_pro_certification", 1, expires_in: 5.minutes)
end
end
sms_notify_admin
end
private
@ -61,7 +57,11 @@ class Users::ApplyProfessionalAuthService < ApplicationService
end
def sms_notify_admin
Educoder::Sms.notify_admin(send_type: 'apply_pro_certification')
sms_cache = Rails.cache.read('apply_pro_certification')
if sms_cache.nil?
Educoder::Sms.notify_admin(send_type: 'apply_pro_certification')
Rails.cache.write('apply_pro_certification', 1, expires_in: 5.minutes)
end
rescue => ex
Util.logger_error(ex)
end

Loading…
Cancel
Save