Description:
- fix ssl, we no longer check SSL for the API call to chula
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r585:0d6ca27c4e8d - - 4 files changed: 8 inserted, 7 deleted

@@ -108,21 +108,22
108 }
108 }
109
109
110 #simple call
110 #simple call
111 begin
111 begin
112 http = Net::HTTP.new('www.cas.chula.ac.th', 443)
112 http = Net::HTTP.new('www.cas.chula.ac.th', 443)
113 http.use_ssl = true
113 http.use_ssl = true
114 + http.verify_mode = OpenSSL::SSL::VERIFY_NONE
114 result = [ ]
115 result = [ ]
115 http.start do |http|
116 http.start do |http|
116 req = Net::HTTP::Post.new('/cas/api/?q=studentAuthenticate')
117 req = Net::HTTP::Post.new('/cas/api/?q=studentAuthenticate')
117 param = "appid=#{appid}&appsecret=#{appsecret}&username=#{login}&password=#{password}"
118 param = "appid=#{appid}&appsecret=#{appsecret}&username=#{login}&password=#{password}"
118 resp = http.request(req,param)
119 resp = http.request(req,param)
119 result = JSON.parse resp.body
120 result = JSON.parse resp.body
120 end
121 end
121 return true if result["type"] == "beanStudent"
122 return true if result["type"] == "beanStudent"
122 - rescue
123 + rescue => e
123 return false
124 return false
124 end
125 end
125 return false
126 return false
126 end
127 end
127
128
128 def admin?
129 def admin?
@@ -236,13 +237,13
236 return true
237 return true
237 end
238 end
238 end
239 end
239
240
240 def update_start_time
241 def update_start_time
241 stat = self.contest_stat
242 stat = self.contest_stat
242 - if (stat.nil?) or (stat.started_at.nil?)
243 + if stat.nil? or stat.started_at.nil?
243 stat ||= UserContestStat.new(:user => self)
244 stat ||= UserContestStat.new(:user => self)
244 stat.started_at = Time.now.gmtime
245 stat.started_at = Time.now.gmtime
245 stat.save
246 stat.save
246 end
247 end
247 end
248 end
248
249
@@ -1,11 +1,11
1
1
2 %td= grader.host
2 %td= grader.host
3 %td= grader.pid
3 %td= grader.pid
4 %td= grader.mode
4 %td= grader.mode
5 - %td= grader.updated_at.strftime("%H:%M:%S") unless grader.updated_at.nil?
5 + %td= grader.updated_at.strftime("%H:%M:%S") if grader.updated_at
6 %td= grader.task_type
6 %td= grader.task_type
7 %td
7 %td
8 - - if grader.task_id.nil?
8 + - unless grader.task_id
9 idle
9 idle
10 - else
10 - else
11 = link_to "#{grader.task_id}", :action => 'view', :id => grader.task_id, :type => grader.task_type
11 = link_to "#{grader.task_id}", :action => 'view', :id => grader.task_id, :type => grader.task_type
@@ -19,8 +19,8
19 = " | "
19 = " | "
20 = link_to '[detailed result]', :action => 'result', :id => submission.id
20 = link_to '[detailed result]', :action => 'result', :id => submission.id
21 = " | "
21 = " | "
22 = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true})
22 = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true})
23 = " | "
23 = " | "
24 = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
24 = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
25 - //= " | "
25 + = " | "
26 - //= link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id)
26 + = link_to "[#{t 'main.submissions_link'}]", :action => 'submission', :id => problem_name
@@ -45,13 +45,13
45 - total,num_passed = 0,0
45 - total,num_passed = 0,0
46 - sc.each_index do |i|
46 - sc.each_index do |i|
47 - if i == 0
47 - if i == 0
48 %td= link_to sc[i].login, controller: 'users', action: 'profile', id: sc[i]
48 %td= link_to sc[i].login, controller: 'users', action: 'profile', id: sc[i]
49 %td= sc[i].full_name
49 %td= sc[i].full_name
50 %td= sc[i].activated
50 %td= sc[i].activated
51 - %td= sc[i].try(:contest_stat).try(:started_at)!=nil ? 'yes' : 'no'
51 + %td= sc[i].try(:contest_stat).try(:started_at) ? 'yes' : 'no'
52 %td= sc[i].contests.collect {|c| c.name}.join(', ')
52 %td= sc[i].contests.collect {|c| c.name}.join(', ')
53 %td= sc[i].remark
53 %td= sc[i].remark
54 - else
54 - else
55 %td.text-right= sc[i][0]
55 %td.text-right= sc[i][0]
56 - total += sc[i][0]
56 - total += sc[i][0]
57 - num_passed += 1 if sc[i][1]
57 - num_passed += 1 if sc[i][1]
You need to be logged in to leave comments. Login now