Class: Notee::TokensController
Instance Method Summary
collapse
#restrict_access_json, #set_request_filter
Instance Method Details
#check_recaptcha ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/notee/tokens_controller.rb', line 32
def check_recaptcha
endpoint = 'https://www.google.com/recaptcha/api/siteverify?secret=' + Notee.recaptcha_secret_key + '&response=' + params["g-recaptcha-response"]
uri = URI.parse(endpoint)
json = Net::HTTP.get(uri)
result = JSON.parse(json)
if result["success"] == false
raise
end
end
|
#create ⇒ Object
15
16
17
18
19
|
# File 'app/controllers/notee/tokens_controller.rb', line 15
def create
check_recaptcha if Rails.env.production?
User.sign_in(params[:id], params[:password])
redirect_to root_path
end
|
#destroy ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/notee/tokens_controller.rb', line 21
def destroy
respond_to do |format|
if @token = Token.find_by_access_token(session[:access_token]).destroy!
session.delete(:access_token)
format.json { render json: @token, status: 200 }
else
format.json { render json: @token.errors, status: :unprocessable_entity }
end
end
end
|
#new ⇒ Object
12
13
|
# File 'app/controllers/notee/tokens_controller.rb', line 12
def new
end
|