Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Code:
Selected Language:
Show Linenumbers:
Short link for Twitter:
HTML:

HTML view:

Copy Source | Copy HTML
require 'digest/sha1'
 
class User < ActiveRecord::Base
  include Authentication
  include Authentication::ByPassword
  include Authentication::ByCookieToken
 
  validates_format_of :name, :with => Authentication.name_regex, :message => Authentication.bad_name_message, :allow_nil => true
  validates_length_of :name, :maximum => 100
 
  validates_presence_of :email
  validates_length_of :email, :within => 6..100
  validates_uniqueness_of :email
  validates_format_of :email, :with => Authentication.email_regex, :message => Authentication.bad_email_message
 
  attr_accessible :email, :name, :password, :password_confirmation
 
  def self.authenticate(login, password)
    return nil if login.blank? || password.blank?
    u = find_by_email(login.downcase) # need to get the salt
    u && u.authenticated?(password) ? u : nil
  end
 
  def email=(value)
    write_attribute :email, (value ? value.downcase : nil)
  end
end




Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2012