Skip to content

Instantly share code, notes, and snippets.

View ouranos's full-sized avatar

Olivier Brisse ouranos

View GitHub Profile
# config/routes.rb
Rails.application.routes.draw do
get 'welcome/index'.
root 'welcome#index'
end
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :username
t.string :authentication_token
t.string :password_digest
t.timestamps null: false
t.index :authentication_token, unique: true
# config/application.rb
# Add Warden in the middleware stack
config.middleware.insert_after ActionDispatch::ParamsParser, Warden::Manager do |manager|
end
# lib/strategies/authentication_token_strategy.rb
class AuthenticationTokenStrategy < ::Warden::Strategies::Base
def valid?
authentication_token
end
def authenticate!
user = User.find_by_authentication_token(authentication_token)
user.nil? ? fail!('strategies.authentication_token.failed') : success!(user)
end
# config/application.rb
# Add Warden in the middleware stack
config.middleware.insert_after ActionDispatch::Flash, Warden::Manager do |manager|
manager.default_strategies :authentication_token
end
# app/controllers/application_controller.rb
class ApplicationController < ActionController::API
include WardenHelper
end
# config/application.rb
config.middleware.insert_after ActionDispatch::Flash, Warden::Manager do |manager|
manager.default_strategies :authentication_token
manager.failure_app = UnauthorizedController
end
# config/application.rb
config.middleware.insert_after ActionDispatch::Flash, Warden::Manager do |manager|
manager.default_strategies :authentication_token, :basic_auth
manager.failure_app = UnauthorizedController
end
CmdUtils.CreateCommand(
{
name: "ruby",
takes: {"function": noun_arb_text},
icon: "http://ruby-doc.org/favicon.ico",
homepage: "http://jackndempsey.blogspot.com",
author: {name: "Jack Dempsey", email: "jack.dempsey@gmail.com"},
license: "MPL,GPL",
description: "Search ruby functions documentation",
help: "Select a ruby function",

Terms of Service

Last revised on [DATE]

The Gist

[COMPANY] operates the [SERVICE] service, which we hope you use. If you use it, please use it responsibly. If you don't, we'll have to terminate your account.

For paid accounts, you'll be charged on a monthly basis. You can cancel anytime, but there are no refunds.