Skip to content

renholm/kthid_authentication

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Install and use

1. Install the the plugin

$ script/plugin install git://github.com/renholm/kthid_authentication.git

2. Make some changes to your database

class AddKthIdentifierToUser < ActiveRecord::Migration
  def self.up
    add_column :users, :kth_identifier, :string, :limit => 10
  end

  def self.down
    remove_column :users, :kth_identifier
  end
end

3. Use it!

authenticate_with_kthid(:service => new_sessions_url) do |result,account|
  if result.successful?
    user = User.find_or_initialize_by_kth_identifier(account.identifier)
    if user.new_record?
      user.username = account.username
      user.save!
    end
    redirect_and_set_user(user)
  else
    # Handle failures
  end
end

About

Authentication helper for login using the KTH login service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages