Created
March 3, 2011 05:14
-
-
Save nickhammond/852369 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# if you look in clearance/lib/clearance/user.rb you can see the encryption method | |
# | |
# def encrypt(string) | |
# generate_hash("--#{salt}--#{string}--") | |
# end | |
# | |
# lib/clearance_crypto.rb | |
class ClearanceCrypto | |
def self.encrypt(*tokens) | |
Digest::SHA1.hexdigest("--#{tokens[1]}--#{tokens[0]}--") | |
end | |
def self.matches?(crypted_password, *tokens) | |
# tokens = ["plain text password", "password_salt"] | |
# crypted_password = crypted_password in db | |
encrypt(*tokens) == crypted_password | |
end | |
end | |
# your model that needs authentication | |
# app/models/user.rb | |
class User < ActiveRecord::Base | |
acts_as_authentic do |c| | |
c.transition_from_crypto_providers = ClearanceCrypto, | |
c.crypto_provider = Authlogic::CryptoProviders::Sha512 | |
end | |
end | |
# If you you have problems logging in make sure you don't have any of the "magic" | |
# fields set to something that would deny a login such as an "active" field set to | |
# 0. You can also turn off magic fields too and session management within | |
# authlogic. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment