Skip to content

Instantly share code, notes, and snippets.

View johnnytomcat's full-sized avatar
📺

Jonathan Haar johnnytomcat

📺
View GitHub Profile
# frozen_string_literal: true
class ApplicationController < ActionController::Base
# protect_from_forgery with: :exception
respond_to :json, :html
before_action :authenticate_user!
end
# frozen_string_literal: true
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :invitable, :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:jwt_authenticatable, jwt_revocation_strategy: Devise::JWT::RevocationStrategies::Null
end
gem 'devise-jwt'
gem 'rack-cors'
config.jwt do |jwt|
jwt.secret = ENV['DEVISE_JWT_SECRET_KEY']
jwt.request_formats = {
user: [:json]
}
end
config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '*',
:headers => :any,
:methods => [:get, :post, :options],
expose: %w(Authorization)
end
end
# frozen_string_literal: true
class SessionsController < Devise::SessionsController
def create
super { @token = current_token }
end
private
def current_token
@johnnytomcat
johnnytomcat / git-clean-branches.sh
Last active October 4, 2018 15:21
Script to remove local branches that no longer exist in origin.
for branch in $(git branch -vv | grep 'origin/.*: gone]' ) ; do git branch -D $branch ; done ;