authentasaurus 0.4.14 → 0.5.6

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.
Files changed (36) hide show
  1. data/CHANGELIST +3 -0
  2. data/TODO +4 -4
  3. data/app/controllers/areas_controller.rb +2 -1
  4. data/app/controllers/groups_controller.rb +2 -1
  5. data/app/controllers/permissions_controller.rb +2 -1
  6. data/app/controllers/recoveries_controller.rb +2 -1
  7. data/app/controllers/registrations_controller.rb +2 -1
  8. data/app/controllers/sessions_controller.rb +2 -1
  9. data/app/controllers/user_invitations_controller.rb +2 -1
  10. data/app/controllers/users_controller.rb +2 -1
  11. data/app/controllers/validations_controller.rb +2 -1
  12. data/app/models/area.rb +2 -1
  13. data/app/models/group.rb +2 -1
  14. data/app/models/permission.rb +2 -1
  15. data/app/models/recovery.rb +2 -1
  16. data/app/models/session.rb +2 -1
  17. data/app/models/user_invitation.rb +2 -1
  18. data/app/models/validation.rb +2 -1
  19. data/lib/authentasaurus/areas_controller.rb +77 -68
  20. data/lib/authentasaurus/groups_controller.rb +78 -70
  21. data/lib/authentasaurus/models/area.rb +15 -6
  22. data/lib/authentasaurus/models/group.rb +15 -6
  23. data/lib/authentasaurus/models/permission.rb +19 -8
  24. data/lib/authentasaurus/models/recovery.rb +31 -21
  25. data/lib/authentasaurus/models/session.rb +59 -50
  26. data/lib/authentasaurus/models/user_invitation.rb +26 -16
  27. data/lib/authentasaurus/models/validation.rb +25 -15
  28. data/lib/authentasaurus/permissions_controller.rb +78 -69
  29. data/lib/authentasaurus/recoveries_controller.rb +62 -52
  30. data/lib/authentasaurus/registrations_controller.rb +34 -24
  31. data/lib/authentasaurus/sessions_controller.rb +42 -33
  32. data/lib/authentasaurus/user_invitations_controller.rb +36 -27
  33. data/lib/authentasaurus/users_controller.rb +77 -68
  34. data/lib/authentasaurus/validations_controller.rb +38 -28
  35. metadata +7 -6
  36. data/app/controllers/authentasaurus/authentasaurus_controller.rb +0 -2
@@ -1,60 +1,70 @@
1
- class Authentasaurus::RecoveriesController < Authentasaurus::AuthentasaurusController
2
- def new
3
- @recovery = Recovery.new
4
-
5
- respond_to do |format|
6
- format.html
7
- end
1
+ module Authentasaurus::RecoveriesController
2
+ def self.included(base) # :nodoc:
3
+ base.send :extend, ClassMethods
4
+ base.send :include, InstanceMethods
8
5
  end
9
6
 
10
- def create
11
- @recovery = Recovery.find_or_initialize_by_email :email => params[:email]
12
-
13
- if @recovery.new_record?
14
- @recovery.user = User.find_by_email @recovery.email
7
+ module ClassMethods
8
+ end
9
+
10
+ module InstanceMethods
11
+ def new
12
+ @recovery = Recovery.new
13
+
14
+ respond_to do |format|
15
+ format.html
16
+ end
15
17
  end
16
18
 
17
- respond_to do |format|
18
- if @recovery.save
19
- @recovery.touch
20
- format.html { redirect_to new_session_path, :notice => t(:recovery_email_sent, :scope => [:authentasaurus, :messages, :recoveries], :email => @recovery.email) }
21
- else
22
- format.html {render :new}
19
+ def create
20
+ @recovery = Recovery.find_or_initialize_by_email :email => params[:email]
21
+
22
+ if @recovery.new_record?
23
+ @recovery.user = User.find_by_email @recovery.email
23
24
  end
24
- end
25
- end
26
-
27
- def edit
28
- @recovery = Recovery.valid.find_by_token(params[:token])
29
-
30
- respond_to do |format|
31
- unless @recovery.nil?
32
- @user = @recovery.user
33
- format.html
34
- else
35
- format.html { redirect_to new_session_path, :alert => t(:recovery_failed, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email]) }
36
- end
37
- end
38
- end
25
+
26
+ respond_to do |format|
27
+ if @recovery.save
28
+ @recovery.touch
29
+ format.html { redirect_to new_session_path, :notice => t(:recovery_email_sent, :scope => [:authentasaurus, :messages, :recoveries], :email => @recovery.email) }
30
+ else
31
+ format.html {render :new}
32
+ end
33
+ end
34
+ end
39
35
 
40
- def destroy
41
- @recovery = Recovery.find_by_token params[:token]
42
- @user = @recovery.user
43
-
44
- respond_to do |format|
45
- empty_fields = params[:user].select { |key, value| value.blank? }
46
- if !empty_fields.empty?
47
- empty_fields.each do |f|
48
- @user.errors.add_to_base t(:recovery_field_blank, :scope => [:authentasaurus, :messages, :recoveries], :field => f.first.humanize)
49
- end
50
- format.html { render :edit }
51
- elsif @user.update_attributes params[:user]
52
- @recovery.destroy
53
- format.html { redirect_to new_session_path, :notice => t(:recovery_successful, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email]) }
54
- else
55
- flash.now[:alert] = t(:recovery_failed, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email])
56
- format.html { render :edit }
57
- end
58
- end
36
+ def edit
37
+ @recovery = Recovery.valid.find_by_token(params[:token])
38
+
39
+ respond_to do |format|
40
+ unless @recovery.nil?
41
+ @user = @recovery.user
42
+ format.html
43
+ else
44
+ format.html { redirect_to new_session_path, :alert => t(:recovery_failed, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email]) }
45
+ end
46
+ end
47
+ end
48
+
49
+ def destroy
50
+ @recovery = Recovery.find_by_token params[:token]
51
+ @user = @recovery.user
52
+
53
+ respond_to do |format|
54
+ empty_fields = params[:user].select { |key, value| value.blank? }
55
+ if !empty_fields.empty?
56
+ empty_fields.each do |f|
57
+ @user.errors.add_to_base t(:recovery_field_blank, :scope => [:authentasaurus, :messages, :recoveries], :field => f.first.humanize)
58
+ end
59
+ format.html { render :edit }
60
+ elsif @user.update_attributes params[:user]
61
+ @recovery.destroy
62
+ format.html { redirect_to new_session_path, :notice => t(:recovery_successful, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email]) }
63
+ else
64
+ flash.now[:alert] = t(:recovery_failed, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email])
65
+ format.html { render :edit }
66
+ end
67
+ end
68
+ end
59
69
  end
60
70
  end
@@ -1,32 +1,42 @@
1
- class Authentasaurus::RegistrationsController < Authentasaurus::AuthentasaurusController
2
- def new
3
- @user = User.new
4
- @user_invitation = UserInvitation.find_by_token params[:token]
5
-
6
- respond_to do |format|
7
- if @user_invitation.nil?
8
- format.html {redirect_to new_session_path, :alert => t(:invalid_invitation_token, :scope => [:authentasaurus, :messages, :user_invitations])}
9
- else
10
- @user.email = @user_invitation.email
11
- format.html
1
+ module Authentasaurus::RegistrationsController
2
+ def self.included(base) # :nodoc:
3
+ base.send :extend, ClassMethods
4
+ base.send :include, InstanceMethods
5
+ end
6
+
7
+ module ClassMethods
8
+ end
9
+
10
+ module InstanceMethods
11
+ def new
12
+ @user = User.new
13
+ @user_invitation = UserInvitation.find_by_token params[:token]
14
+
15
+ respond_to do |format|
16
+ if @user_invitation.nil?
17
+ format.html {redirect_to new_session_path, :alert => t(:invalid_invitation_token, :scope => [:authentasaurus, :messages, :user_invitations])}
18
+ else
19
+ @user.email = @user_invitation.email
20
+ format.html
21
+ end
12
22
  end
13
23
  end
14
- end
15
-
16
- def create
17
- @user = User.new params[:user]
18
- user_invitation = UserInvitation.find_by_token params[:token]
19
-
20
- respond_to do |format|
21
- unless user_invitation.nil?
22
- if @user.save
23
- format.html {redirect_to new_session_path}
24
+
25
+ def create
26
+ @user = User.new params[:user]
27
+ user_invitation = UserInvitation.find_by_token params[:token]
28
+
29
+ respond_to do |format|
30
+ unless user_invitation.nil?
31
+ if @user.save
32
+ format.html {redirect_to new_session_path}
33
+ else
34
+ format.html {render :new}
35
+ end
24
36
  else
37
+ flash.now[:alert] = t(:invalid_invitation_token, :scope => [:authentasaurus, :messages, :user_invitations])
25
38
  format.html {render :new}
26
39
  end
27
- else
28
- flash.now[:alert] = t(:invalid_invitation_token, :scope => [:authentasaurus, :messages, :user_invitations])
29
- format.html {render :new}
30
40
  end
31
41
  end
32
42
  end
@@ -1,45 +1,54 @@
1
- class Authentasaurus::SessionsController < Authentasaurus::AuthentasaurusController
2
- before_filter :check_is_logged_in, :except => [:destroy, :no_access]
3
-
4
- def new
5
- @session = Session.new
1
+ module Authentasaurus::SessionsController
2
+ def self.included(base) # :nodoc:
3
+ base.send :extend, ClassMethods
4
+ base.send :include, InstanceMethods
6
5
 
7
- respond_to do |format|
8
- format.html
9
- end
6
+ base.send :before_filter, :check_is_logged_in, :except => [:destroy, :no_access]
7
+ end
8
+
9
+ module ClassMethods
10
10
  end
11
11
 
12
- def create
13
- @session = Session.new params[:session]
12
+ module InstanceMethods
13
+ def new
14
+ @session = Session.new
15
+
16
+ respond_to do |format|
17
+ format.html
18
+ end
19
+ end
14
20
 
15
- respond_to do |format|
16
- if @session.save
17
- if @session.remember == "1"
18
- cookies.signed.permanent[:remember_me_token] = @session.user.remember_me_token
21
+ def create
22
+ @session = Session.new params[:session]
23
+
24
+ respond_to do |format|
25
+ if @session.save
26
+ if @session.remember == "1"
27
+ cookies.signed.permanent[:remember_me_token] = @session.user.remember_me_token
28
+ end
29
+ session[:user_id] = @session.user.id
30
+ session[:user_permissions] = {:read => @session.user.permissions.collect{|per| per.area.name if per.read}, :write => @session.user.permissions.collect{|per| per.area.name if per.write}}
31
+ format.html { redirect_to session[:original_url] || root_url }
32
+ else
33
+ format.html { render :action => :new }
19
34
  end
20
- session[:user_id] = @session.user.id
21
- session[:user_permissions] = {:read => @session.user.permissions.collect{|per| per.area.name if per.read}, :write => @session.user.permissions.collect{|per| per.area.name if per.write}}
22
- format.html { redirect_to session[:original_url] || root_url }
23
- else
24
- format.html { render :action => :new }
25
35
  end
36
+
26
37
  end
27
38
 
28
- end
29
-
30
- def destroy
31
- session[:user_id] = nil
32
- session[:user_permissions] = nil
33
- cookies.delete :remember_me_token
39
+ def destroy
40
+ session[:user_id] = nil
41
+ session[:user_permissions] = nil
42
+ cookies.delete :remember_me_token
43
+
44
+ respond_to do |format|
45
+ format.html { redirect_to :action => :new }
46
+ end
47
+ end
34
48
 
35
- respond_to do |format|
36
- format.html { redirect_to :action => :new }
49
+ private
50
+ def check_is_logged_in
51
+ redirect_to root_path if session[:user_id]
37
52
  end
38
53
  end
39
-
40
- private
41
- def check_is_logged_in
42
- redirect_to root_path if session[:user_id]
43
- end
44
-
45
54
  end
@@ -1,39 +1,48 @@
1
- class Authentasaurus::UserInvitationsController < Authentasaurus::AuthentasaurusController
1
+ module Authentasaurus::UserInvitationsController
2
+ def self.included(base) # :nodoc:
3
+ base.send :extend, ClassMethods
4
+ base.send :include, InstanceMethods
5
+ end
2
6
 
3
- def index
4
- @invitations = UserInvitation.find :all
5
-
6
- respond_to do |format|
7
- format.html
8
- end
7
+ module ClassMethods
9
8
  end
10
9
 
11
- def new
12
- @invitation = UserInvitation.new
10
+ module InstanceMethods
11
+ def index
12
+ @invitations = UserInvitation.find :all
13
+
14
+ respond_to do |format|
15
+ format.html
16
+ end
17
+ end
13
18
 
14
- respond_to do |format|
15
- format.html
19
+ def new
20
+ @invitation = UserInvitation.new
21
+
22
+ respond_to do |format|
23
+ format.html
24
+ end
16
25
  end
17
- end
18
-
19
- def create
20
- @invitation = UserInvitation.new params[:user_invitation]
21
26
 
22
- respond_to do |format|
23
- if @invitation.save
24
- format.html { redirect_to :action => :index }
25
- else
26
- format.html {render :new}
27
+ def create
28
+ @invitation = UserInvitation.new params[:user_invitation]
29
+
30
+ respond_to do |format|
31
+ if @invitation.save
32
+ format.html { redirect_to :action => :index }
33
+ else
34
+ format.html {render :new}
35
+ end
27
36
  end
28
37
  end
29
- end
30
-
31
- def destroy
32
- invitation = UserInvitation.find params[:id]
33
- invitation.destroy
34
38
 
35
- respond_to do |format|
36
- format.html { redirect_to :action => :index }
39
+ def destroy
40
+ invitation = UserInvitation.find params[:id]
41
+ invitation.destroy
42
+
43
+ respond_to do |format|
44
+ format.html { redirect_to :action => :index }
45
+ end
37
46
  end
38
47
  end
39
48
  end
@@ -1,69 +1,78 @@
1
- class Authentasaurus::UsersController < Authentasaurus::AuthentasaurusController
2
-
3
- def index
4
- @users = User.all
5
-
6
- respond_to do |format|
7
- format.html
8
- end
9
- end
10
-
11
- def show
12
- @user = User.find(params[:id])
13
-
14
- respond_to do |format|
15
- format.html
16
- end
17
- end
18
-
19
- def new
20
- @user = User.new
21
-
22
- respond_to do |format|
23
- format.html
24
- end
25
- end
26
-
27
- def create
28
- @user = User.new params[:user]
29
-
30
- respond_to do |format|
31
- if @user.save
32
- format.html { redirect_to :action=>:index, :notice => "User saved successfully" }
33
- else
34
- flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :users])
35
- format.html { render :new }
36
- end
37
- end
38
- end
39
-
40
- def edit
41
- @user = User.find params[:id]
42
-
43
- respond_to do |format|
44
- format.html
45
- end
46
- end
47
-
48
- def update
49
- @user = User.find params[:id]
50
-
51
- respond_to do |format|
52
- if @user.update_attributes(params[:user])
53
- format.html { redirect_to @user, :notice => "User updated" }
54
- else
55
- flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :users])
56
- format.html { render :edit }
57
- end
58
- end
59
- end
60
-
61
- def destroy
62
- @user = User.find params[:id]
63
- @user.destroy
64
-
65
- respond_to do |format|
66
- format.html { redirect_to :action=>:index }
67
- end
68
- end
1
+ module Authentasaurus::UsersController
2
+ def self.included(base) # :nodoc:
3
+ base.send :extend, ClassMethods
4
+ base.send :include, InstanceMethods
5
+ end
6
+
7
+ module ClassMethods
8
+ end
9
+
10
+ module InstanceMethods
11
+ def index
12
+ @users = User.all
13
+
14
+ respond_to do |format|
15
+ format.html
16
+ end
17
+ end
18
+
19
+ def show
20
+ @user = User.find(params[:id])
21
+
22
+ respond_to do |format|
23
+ format.html
24
+ end
25
+ end
26
+
27
+ def new
28
+ @user = User.new
29
+
30
+ respond_to do |format|
31
+ format.html
32
+ end
33
+ end
34
+
35
+ def create
36
+ @user = User.new params[:user]
37
+
38
+ respond_to do |format|
39
+ if @user.save
40
+ format.html { redirect_to :action=>:index, :notice => "User saved successfully" }
41
+ else
42
+ flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :users])
43
+ format.html { render :new }
44
+ end
45
+ end
46
+ end
47
+
48
+ def edit
49
+ @user = User.find params[:id]
50
+
51
+ respond_to do |format|
52
+ format.html
53
+ end
54
+ end
55
+
56
+ def update
57
+ @user = User.find params[:id]
58
+
59
+ respond_to do |format|
60
+ if @user.update_attributes(params[:user])
61
+ format.html { redirect_to @user, :notice => "User updated" }
62
+ else
63
+ flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :users])
64
+ format.html { render :edit }
65
+ end
66
+ end
67
+ end
68
+
69
+ def destroy
70
+ @user = User.find params[:id]
71
+ @user.destroy
72
+
73
+ respond_to do |format|
74
+ format.html { redirect_to :action=>:index }
75
+ end
76
+ end
77
+ end
69
78
  end