appoxy_sessions 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/sessions/sessions_controller.rb +3 -3
- data/lib/sessions/user.rb +14 -9
- metadata +1 -1
@@ -18,9 +18,9 @@ module Appoxy
|
|
18
18
|
end
|
19
19
|
|
20
20
|
if @has_password == "true"
|
21
|
-
user = User.
|
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
|
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
|
45
|
-
return nil if
|
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
|
49
|
-
|
50
|
-
|
53
|
+
if attributes["password"][0].length < 100
|
54
|
+
self.password = attributes["password"][0]
|
55
|
+
self.save
|
51
56
|
end
|
52
57
|
|
53
|
-
(
|
58
|
+
(self.password == password) ? u : nil
|
54
59
|
end
|
55
60
|
|
56
61
|
|