Class: Ishapi::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Ishapi::ApplicationController
- Defined in:
- app/controllers/ishapi/application_controller.rb
Direct Known Subclasses
AddressesController, ArticlesController, CitiesController, EventsController, GalleriesController, GameuiController, InvoicesController, MapsController, MeasurementsController, My::GalleriesController, My::ReportsController, My::VideosController, NewsitemsController, OrderItemsController, OrdersController, PaymentsController, PhotosController, ReportsController, SitesController, StockWatchesController, TagsController, UserProfilesController, UsersController, VenuesController, VideosController
Instance Method Summary collapse
- #home ⇒ Object
-
#long_term_token ⇒ Object
POST /api/users/long_term_token , a FB login flow.
-
#vote ⇒ Object
@TODO: implement completely! vp 2022-08-24.
Instance Method Details
#home ⇒ Object
4 5 6 |
# File 'app/controllers/ishapi/application_controller.rb', line 4 def home render json: { status: :ok }, status: :ok end |
#long_term_token ⇒ Object
POST /api/users/long_term_token , a FB login flow
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/ishapi/application_controller.rb', line 9 def long_term_token accessToken = request.headers[:accessToken] accessToken ||= params[:accessToken] params['domain'] = 'tgm.piousbox.com' response = ::HTTParty.get "https://graph.facebook.com/v5.0/oauth/access_token?grant_type=fb_exchange_token&" + "client_id=#{::FB[params['domain']][:app]}&client_secret=#{::FB[params['domain']][:secret]}&" + "fb_exchange_token=#{accessToken}" j = JSON.parse response.body @long_term_token = j['access_token'] @graph = Koala::Facebook::API.new( accessToken ) @me = @graph.get_object( 'me', :fields => 'email' ) @current_user = User.where( :email => @me['email'] ).first # send the jwt to client @jwt_token = encode(user_id: @current_user.id.to_s) render json: { email: @current_user.email, jwt_token: @jwt_token, long_term_token: @long_term_token, n_unlocks: @current_user.profile.n_unlocks, } end |
#vote ⇒ Object
@TODO: implement completely! vp 2022-08-24
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/ishapi/application_controller.rb', line 36 def vote votee = params[:votee_class_name].constantize.find(params[:votee_id]) :open_permission, Ishapi # @TODO: make this more rigid out = votee.vote(voter_id: params[:voter_id], value: params[:value].to_sym) if out render json: { status: 'ok', } else render json: { status: 'not_ok', message: votee.errors..join(', '), } end end |