11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/adminlock/adminlock_controller.rb', line 11
def unlock
if params[:adminlock_codeword].present?
user_agent = request.env['HTTP_USER_AGENT'].presence
if user_agent && user_agent.downcase.match(CRAWLER_REGEX)
head :ok
return
end
@codeword = params[:adminlock_codeword].to_s.downcase
@return_to = params[:return_to]
if @codeword == adminlock_codeword.to_s.downcase
set_cookie
run_redirect
end
elsif request.post?
if params[:adminlock].present? && params[:adminlock].respond_to?(:'[]')
@codeword = params[:adminlock][:codeword].to_s.downcase
@return_to = params[:adminlock][:return_to]
if @codeword == adminlock_codeword.to_s.downcase
set_cookie
run_redirect
else
@wrong = true
end
else
head :ok
end
else
respond_to :html
end
end
|