appoxy_sessions 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,9 +18,9 @@ module Appoxy
18
18
  end
19
19
 
20
20
  if @has_password == "true"
21
- user = User.authenticate(@email, params[:password])
22
-
23
- if user
21
+ @user = User.find_by_email(@email)
22
+ # user = User.authenticate(@email, params[:password])
23
+ if @user && @user.authenticate(params[:password])
24
24
  self.current_user = user
25
25
  flash[:info] = "Logged in successfully."
26
26
  orig_url = session[:return_to]
data/lib/sessions/user.rb CHANGED
@@ -4,6 +4,11 @@ module Appoxy
4
4
 
5
5
  class User < SimpleRecord::Base
6
6
 
7
+ def self.included(base)
8
+ puts self.class.name + " included in " + base.class.name
9
+ end
10
+
11
+
7
12
  has_strings :email,
8
13
  {:name => :password, :hashed=>true},
9
14
  :first_name,
@@ -36,21 +41,21 @@ module Appoxy
36
41
  end
37
42
 
38
43
 
39
- def self.authenticate(email, password)
44
+ def authenticate(password)
40
45
  #RAILS_DEFAULT_LOGGER.info "-------authenticating password------"
41
46
 
42
- u = self.find :first, :conditions => ["email = ?", email]
43
- return nil unless u
44
- return nil unless u.is_active?
45
- return nil if u.attributes["password"].nil? # if the user has no password (will this happen? maybe for invites...)
47
+ # u = self.find :first, :conditions => ["email = ?", email]
48
+ # return nil unless u
49
+ return nil unless is_active?
50
+ return nil if attributes["password"].nil? # if the user has no password (will this happen? maybe for invites...)
46
51
 
47
52
  # This is a normal unencrypted password
48
- if u.attributes["password"][0].length < 100
49
- u.password = u.attributes["password"][0]
50
- u.save
53
+ if attributes["password"][0].length < 100
54
+ self.password = attributes["password"][0]
55
+ self.save
51
56
  end
52
57
 
53
- (u.password == password) ? u : nil
58
+ (self.password == password) ? u : nil
54
59
  end
55
60
 
56
61
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appoxy_sessions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Reeder