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 Pundit
|
||||||
include PunditExtra
|
include PunditExtra
|
||||||
rescue_from Pundit::NotAuthorizedError, with: :handle_unauthorized
|
rescue_from Pundit::NotAuthorizedError, with: :handle_unauthorized
|
||||||
protect_from_forgery(with: :exception)
|
|
||||||
|
|
||||||
before_action :invite_link
|
before_action :invite_link
|
||||||
before_action :prepare_exception_notifier
|
before_action :prepare_exception_notifier
|
||||||
|
|
|
@ -5,6 +5,16 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
respond_to :html, :json
|
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
|
# GET /users/1.json
|
||||||
def show
|
def show
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
|
|
|
@ -70,6 +70,7 @@ class User < ApplicationRecord
|
||||||
json['follow_map_on_contributed'] = settings.follow_map_on_contributed == '1'
|
json['follow_map_on_contributed'] = settings.follow_map_on_contributed == '1'
|
||||||
end
|
end
|
||||||
json['email'] = email if options[:email]
|
json['email'] = email if options[:email]
|
||||||
|
json['emails_allowed'] = emails_allowed if options[:emails_allowed]
|
||||||
json
|
json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,10 @@ Rails.application.configure do
|
||||||
config.log_level = :info
|
config.log_level = :info
|
||||||
config.eager_load = false
|
config.eager_load = false
|
||||||
|
|
||||||
|
config.action_cable.allowed_request_origins = [
|
||||||
|
'http://localhost:3000'
|
||||||
|
]
|
||||||
|
|
||||||
# In the development environment your application's code is reloaded on
|
# In the development environment your application's code is reloaded on
|
||||||
# every request. This slows down response time but is perfect for development
|
# 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.
|
# 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
|
# Settings specified here will take precedence over those in config/application.rb
|
||||||
|
|
||||||
config.action_cable.allowed_request_origins = [
|
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
|
# log to stdout
|
||||||
|
|
|
@ -112,6 +112,9 @@ Metamaps::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :users, except: %i[index destroy] do
|
resources :users, except: %i[index destroy] do
|
||||||
|
collection do
|
||||||
|
get :current
|
||||||
|
end
|
||||||
member do
|
member do
|
||||||
get :details
|
get :details
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue