Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Individuals_Controller
- def login
- if request.post?
- if session[:individual] = Individual.authenticate(params[:individual][:username], params[:individual][:password])
- flash[:message] = "Login successful"
- redirect_to_stored
- else
- flash[:warning] = "Login unsuccessful"
- end
- end
- end
- Individuals Model
- def self.encrypt(string, salt)
- return Digest::SHA1.hexdigest(string+salt)
- end
- def self.authenticate(username, pass)
- resultset=find(:first, :conditions=>["username = ?", username])
- return nil if resultset.nil?
- return resultset if Individual.encrypt(pass, resultset.created_on.to_s[0,19])==resultset.password
- nil
- end
Add Comment
Please, Sign In to add comment