appoxy_sessions 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
@@ -52,15 +52,16 @@ module Appoxy
|
|
52
52
|
if !logged_in?
|
53
53
|
flash[:warning] = "You need to login to access this page."
|
54
54
|
session[:return_to] = request.request_uri # return to after logging in
|
55
|
-
puts "ac=" + params[:
|
56
|
-
if params[:
|
55
|
+
puts "ac=" + params[:ac].inspect
|
56
|
+
if params[:user_id] && params[:ac]
|
57
57
|
# then from an invite
|
58
|
-
user = User.find(params[:
|
59
|
-
# this the best way to decide of user has not logged in? Could also check status.
|
60
|
-
|
61
|
-
|
58
|
+
user = ::User.find(params[:user_id])
|
59
|
+
if user && user.password.blank? # this the best way to decide of user has not logged in? Could also check status.
|
60
|
+
redirect_to :controller=>"users", :action=>"new", :email=>user.email, :ac=>params[:ac]
|
61
|
+
return
|
62
|
+
end
|
62
63
|
end
|
63
|
-
redirect_to :controller=>"sessions", :action=>"new", :
|
64
|
+
redirect_to :controller=>"sessions", :action=>"new", :ac=>params[:ac]
|
64
65
|
end
|
65
66
|
|
66
67
|
after_authenticate
|
@@ -27,10 +27,22 @@ module Appoxy
|
|
27
27
|
|
28
28
|
@user = ::User.new(params[:user])
|
29
29
|
|
30
|
+
if @user.password != params[:password_confirmation]
|
31
|
+
flash[:error] = "Confirmation password does not match. Please try again."
|
32
|
+
render :action=>"new"
|
33
|
+
return
|
34
|
+
end
|
35
|
+
|
36
|
+
if params[:user][:password].length < 6
|
37
|
+
flash[:error] = "Password can not be less than 6 characters."
|
38
|
+
render :action=>"new"
|
39
|
+
return
|
40
|
+
end
|
41
|
+
|
30
42
|
existing_user = ::User.find_by_email(@user.email)
|
31
43
|
|
32
44
|
if existing_user
|
33
|
-
if
|
45
|
+
if @user.activation_code.present?
|
34
46
|
# hasn't logged in yet, probably invited, need to check access key
|
35
47
|
if existing_user.activation_code == @user.activation_code
|
36
48
|
existing_user.activate!
|
@@ -42,23 +54,10 @@ module Appoxy
|
|
42
54
|
render :action=>"new"
|
43
55
|
return
|
44
56
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
if @user.password != params[:password_confirmation]
|
49
|
-
flash[:error] = "Confirmation password does not match. Please try again."
|
50
|
-
render :action=>"new"
|
51
|
-
return
|
52
|
-
end
|
53
|
-
|
54
|
-
if params[:user][:password].length < 6
|
55
|
-
flash[:error] = "Password can not be less than 6 characters."
|
56
|
-
render :action=>"new"
|
57
|
-
return
|
57
|
+
else
|
58
|
+
@user.status = "active"
|
58
59
|
end
|
59
60
|
|
60
|
-
@user.status = "active"
|
61
|
-
|
62
61
|
before_save_in_create
|
63
62
|
if @user.save
|
64
63
|
self.current_user = @user
|
@@ -91,13 +90,13 @@ module Appoxy
|
|
91
90
|
# Usually a user gets here via an activation link in email.
|
92
91
|
def activate
|
93
92
|
logout_keeping_session!
|
94
|
-
@user = User.find_by_activation_code(params[:
|
93
|
+
@user = User.find_by_activation_code(params[:ac]) unless params[:ac].blank?
|
95
94
|
case
|
96
|
-
when (!params[:
|
95
|
+
when (!params[:ac].blank?) && @user && !@user.is_active?
|
97
96
|
flash[:info] = "Account activated. please login."
|
98
97
|
@user.activate!
|
99
98
|
redirect_to login_url
|
100
|
-
when params[:
|
99
|
+
when params[:ac].blank?
|
101
100
|
flash[:error] = "The activation code was missing. Please follow the URL from your email."
|
102
101
|
redirect_to(root_url)
|
103
102
|
else
|