add current user route
This commit is contained in:
parent
955ebdd747
commit
58d81e239b
6 changed files with 19 additions and 2 deletions
|
@ -5,7 +5,6 @@ class ApplicationController < ActionController::Base
|
|||
include Pundit
|
||||
include PunditExtra
|
||||
rescue_from Pundit::NotAuthorizedError, with: :handle_unauthorized
|
||||
protect_from_forgery(with: :exception)
|
||||
|
||||
before_action :invite_link
|
||||
before_action :prepare_exception_notifier
|
||||
|
|
|
@ -5,6 +5,16 @@ class UsersController < ApplicationController
|
|||
|
||||
respond_to :html, :json
|
||||
|
||||
# GET /users/current
|
||||
def current
|
||||
#if current_user
|
||||
# these are just options, saying include these values, they aren't the values themselves
|
||||
render json: current_user.to_json({follows: true, email: true, follow_settings: true, emails_allowed: true})
|
||||
#else
|
||||
# render json: nil
|
||||
#end
|
||||
end
|
||||
|
||||
# GET /users/1.json
|
||||
def show
|
||||
@user = User.find(params[:id])
|
||||
|
|
|
@ -70,6 +70,7 @@ class User < ApplicationRecord
|
|||
json['follow_map_on_contributed'] = settings.follow_map_on_contributed == '1'
|
||||
end
|
||||
json['email'] = email if options[:email]
|
||||
json['emails_allowed'] = emails_allowed if options[:emails_allowed]
|
||||
json
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@ Rails.application.configure do
|
|||
config.log_level = :info
|
||||
config.eager_load = false
|
||||
|
||||
config.action_cable.allowed_request_origins = [
|
||||
'http://localhost:3000'
|
||||
]
|
||||
|
||||
# In the development environment your application's code is reloaded on
|
||||
# every request. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the web server when you make code changes.
|
||||
|
|
|
@ -5,7 +5,7 @@ Rails.application.configure do
|
|||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
config.action_cable.allowed_request_origins = [
|
||||
'https://metamaps.herokuapp.com', 'http://metamaps.herokuapp.com', 'https://metamaps.cc'
|
||||
'https://metamaps.herokuapp.com', 'https://metamaps.cc'
|
||||
]
|
||||
|
||||
# log to stdout
|
||||
|
|
|
@ -112,6 +112,9 @@ Metamaps::Application.routes.draw do
|
|||
end
|
||||
|
||||
resources :users, except: %i[index destroy] do
|
||||
collection do
|
||||
get :current
|
||||
end
|
||||
member do
|
||||
get :details
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue