I have custom JSON authentication API (without devise, etc). How do I render @user.authentication_token to response header instead of body?
in sessions_controller.rb
def create
if @user && @user.authenticate(params[:user][:password])
@user.sign_in_count += 1
@user.save!
render status: 200,
json: { success: true,
info: "Logged in sucessfully.",
data: { auth_token: @user.authentication_token } }
else
render status: :unprocessable_entity,
json: { success: false,
info: "Login failed." }
end
end