Class: Notee::TokensController

Inherits:
ApplicationController show all
Defined in:
app/controllers/notee/tokens_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#restrict_access_json, #set_request_filter

Instance Method Details

#check_recaptchaObject



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

#createObject



15
16
17
18
19
# File 'app/controllers/notee/tokens_controller.rb', line 15

def create
  check_recaptcha if Rails.env.production?
  User.(params[:id], params[:password])
  redirect_to root_path
end

#destroyObject



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

#newObject



12
13
# File 'app/controllers/notee/tokens_controller.rb', line 12

def new
end