2015-09-08 13:14:46 +00:00
|
|
|
class UsersController < ApplicationController
|
2018-06-20 17:28:01 +00:00
|
|
|
skip_before_action :verify_authenticity_token, only: :create
|
2015-09-17 14:46:33 +00:00
|
|
|
|
2019-05-08 20:28:09 +00:00
|
|
|
before_action :authenticate_user!, except: [:show, :add_registration_token]
|
|
|
|
before_action :authenticate_user_or_client!, only: [:show, :add_registration_token]
|
2015-09-17 14:46:33 +00:00
|
|
|
|
2019-04-10 09:58:48 +00:00
|
|
|
load_and_authorize_resource find_by: :name
|
2015-09-08 15:40:40 +00:00
|
|
|
|
2015-09-08 15:28:46 +00:00
|
|
|
def show
|
2016-02-04 12:45:12 +00:00
|
|
|
@user = User.find_by(name: params[:id]) || User.new
|
2016-02-10 14:23:16 +00:00
|
|
|
authorize! :read, @user
|
2015-09-08 18:45:32 +00:00
|
|
|
respond_to do |format|
|
2015-09-17 14:46:33 +00:00
|
|
|
format.html { @transaction = Transaction.new }
|
|
|
|
format.json { render json: @user }
|
2015-09-08 18:45:32 +00:00
|
|
|
end
|
2015-09-08 15:28:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
|
|
|
@users = User.all
|
|
|
|
end
|
2018-06-20 17:28:01 +00:00
|
|
|
|
|
|
|
def reset_key
|
|
|
|
@user.generate_key!
|
|
|
|
redirect_to @user
|
|
|
|
end
|
2019-05-08 20:28:09 +00:00
|
|
|
|
|
|
|
def add_registration_token
|
|
|
|
token = JSON.parse(request.raw_post)["token"]
|
|
|
|
respond_to do |format|
|
|
|
|
format.json { render json: AndroidDeviceRegistrationToken.create(user: @user, token: token) }
|
|
|
|
end
|
|
|
|
end
|
2015-09-08 13:14:46 +00:00
|
|
|
end
|