authentasaurus 0.8.4 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELIST +6 -2
- data/TODO +2 -0
- data/app/controllers/sessions_controller.rb +1 -1
- data/app/models/authentasaurus_emailer.rb +6 -6
- data/app/models/{session.rb → authentasaurus_session.rb} +1 -1
- data/app/views/authentasaurus_emailer/invitation_mail.html.erb +2 -2
- data/app/views/authentasaurus_emailer/recovery_mail.html.erb +2 -2
- data/app/views/authentasaurus_emailer/validation_mail.html.erb +2 -2
- data/lib/authentasaurus.rb +5 -1
- data/lib/authentasaurus/ac/acts_as_overrider.rb +6 -5
- data/lib/authentasaurus/ac/controllers/areas_controller.rb +52 -57
- data/lib/authentasaurus/ac/controllers/groups_controller.rb +55 -59
- data/lib/authentasaurus/ac/controllers/permissions_controller.rb +52 -57
- data/lib/authentasaurus/ac/controllers/recoveries_controller.rb +49 -54
- data/lib/authentasaurus/ac/controllers/registrations_controller.rb +23 -28
- data/lib/authentasaurus/ac/controllers/sessions_controller.rb +39 -40
- data/lib/authentasaurus/ac/controllers/user_invitations_controller.rb +29 -34
- data/lib/authentasaurus/ac/controllers/users_controller.rb +51 -56
- data/lib/authentasaurus/ac/controllers/validations_controller.rb +34 -39
- data/lib/authentasaurus/ac/routing.rb +70 -74
- data/lib/authentasaurus/ar/acts_as_authenticatable.rb +58 -64
- data/lib/authentasaurus/ar/acts_as_authenticatable_validatable.rb +13 -16
- data/lib/authentasaurus/ar/acts_as_overrider.rb +1 -3
- data/lib/authentasaurus/ar/authenticatable.rb +1 -3
- data/lib/authentasaurus/ar/migrations.rb +137 -145
- data/lib/authentasaurus/ar/models/recovery.rb +20 -23
- data/lib/authentasaurus/ar/models/session.rb +46 -46
- data/lib/authentasaurus/ar/models/user_invitation.rb +19 -22
- data/lib/authentasaurus/ar/models/validation.rb +12 -15
- data/lib/authentasaurus/arel/acts_as_authenticatable.rb +18 -23
- data/lib/authentasaurus/arel/authenticatable.rb +5 -9
- data/lib/authentasaurus/authorization.rb +11 -8
- data/lib/authentasaurus/configuration.rb +30 -0
- data/lib/authentasaurus/railtie.rb +3 -6
- data/lib/generators/authentasaurus/install/install_generator.rb +1 -2
- data/lib/generators/authentasaurus/install/templates/authentasaurus_tasks.rake +2 -2
- data/lib/generators/authentasaurus/install/templates/defaults.yml +4 -2
- data/lib/generators/authentasaurus/views/templates/authentasaurus_emailer/invitation_mail.html.erb +2 -2
- data/lib/generators/authentasaurus/views/templates/authentasaurus_emailer/recovery_mail.html.erb +2 -2
- data/lib/generators/authentasaurus/views/templates/authentasaurus_emailer/validation_mail.html.erb +2 -2
- data/lib/generators/authentasaurus/views/views_generator.rb +1 -1
- metadata +8 -8
- data/lib/generators/authentasaurus/install/templates/initializer.rb +0 -3
@@ -1,72 +1,67 @@
|
|
1
1
|
module Authentasaurus::Ac::Controllers
|
2
2
|
module RecoveriesController
|
3
|
-
|
4
|
-
base.send :extend, ClassMethods
|
5
|
-
base.send :include, InstanceMethods
|
6
|
-
end
|
3
|
+
extend ActiveSupport::Concern
|
7
4
|
|
8
5
|
module ClassMethods
|
9
6
|
end
|
10
|
-
|
11
|
-
module InstanceMethods
|
12
|
-
def new
|
13
|
-
@recovery = Recovery.new
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
def new
|
9
|
+
@recovery = Recovery.new
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
format.html
|
18
13
|
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
@recovery = Recovery.find_or_initialize_by_email :email => params[:email]
|
19
18
|
|
20
|
-
|
21
|
-
@recovery =
|
22
|
-
|
23
|
-
if @recovery.new_record?
|
24
|
-
@recovery.user = User.find_by_email @recovery.email
|
25
|
-
end
|
26
|
-
|
27
|
-
respond_to do |format|
|
28
|
-
if @recovery.save
|
29
|
-
@recovery.touch
|
30
|
-
format.html { redirect_to new_session_path, :notice => t(:recovery_email_sent, :scope => [:authentasaurus, :messages, :recoveries], :email => @recovery.email) }
|
31
|
-
else
|
32
|
-
format.html {render :new}
|
33
|
-
end
|
34
|
-
end
|
19
|
+
if @recovery.new_record?
|
20
|
+
@recovery.user = User.find_by_email @recovery.email
|
35
21
|
end
|
36
22
|
|
37
|
-
|
38
|
-
@recovery
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
23
|
+
respond_to do |format|
|
24
|
+
if @recovery.save
|
25
|
+
@recovery.touch
|
26
|
+
format.html { redirect_to new_authentasaurus_session_path, :notice => t(:recovery_email_sent, :scope => [:authentasaurus, :messages, :recoveries], :email => @recovery.email) }
|
27
|
+
else
|
28
|
+
format.html {render :new}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def edit
|
34
|
+
@recovery = Recovery.valid.find_by_token(params[:token])
|
35
|
+
|
36
|
+
respond_to do |format|
|
37
|
+
unless @recovery.nil?
|
38
|
+
@user = @recovery.user
|
39
|
+
format.html
|
40
|
+
else
|
41
|
+
format.html { redirect_to new_authentasaurus_session_path, :alert => t(:recovery_failed, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email]) }
|
47
42
|
end
|
48
43
|
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def destroy
|
47
|
+
@recovery = Recovery.find_by_token params[:token]
|
48
|
+
@user = @recovery.user
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
empty_fields = params[:user].select { |key, value| value.blank? }
|
56
|
-
if !empty_fields.empty?
|
57
|
-
empty_fields.each do |f|
|
58
|
-
@user.errors.add_to_base t(:recovery_field_blank, :scope => [:authentasaurus, :messages, :recoveries], :field => f.first.humanize)
|
59
|
-
end
|
60
|
-
format.html { render :edit }
|
61
|
-
elsif @user.update_attributes params[:user]
|
62
|
-
@recovery.destroy
|
63
|
-
format.html { redirect_to new_session_path, :notice => t(:recovery_successful, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email]) }
|
64
|
-
else
|
65
|
-
flash.now[:alert] = t(:recovery_failed, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email])
|
66
|
-
format.html { render :edit }
|
50
|
+
respond_to do |format|
|
51
|
+
empty_fields = params[:user].select { |key, value| value.blank? }
|
52
|
+
if !empty_fields.empty?
|
53
|
+
empty_fields.each do |f|
|
54
|
+
@user.errors.add_to_base t(:recovery_field_blank, :scope => [:authentasaurus, :messages, :recoveries], :field => f.first.humanize)
|
67
55
|
end
|
56
|
+
format.html { render :edit }
|
57
|
+
elsif @user.update_attributes params[:user]
|
58
|
+
@recovery.destroy
|
59
|
+
format.html { redirect_to new_authentasaurus_session_path, :notice => t(:recovery_successful, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email]) }
|
60
|
+
else
|
61
|
+
flash.now[:alert] = t(:recovery_failed, :scope => [:authentasaurus, :messages, :recoveries], :email => params[:email])
|
62
|
+
format.html { render :edit }
|
68
63
|
end
|
69
64
|
end
|
70
65
|
end
|
71
|
-
end
|
66
|
+
end
|
72
67
|
end
|
@@ -1,43 +1,38 @@
|
|
1
1
|
module Authentasaurus::Ac::Controllers
|
2
2
|
module RegistrationsController
|
3
|
-
|
4
|
-
base.send :extend, ClassMethods
|
5
|
-
base.send :include, InstanceMethods
|
6
|
-
end
|
3
|
+
extend ActiveSupport::Concern
|
7
4
|
|
8
5
|
module ClassMethods
|
9
6
|
end
|
10
|
-
|
11
|
-
module InstanceMethods
|
12
|
-
def new
|
13
|
-
@user = User.new
|
14
|
-
@user_invitation = UserInvitation.find_by_token params[:token]
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
8
|
+
def new
|
9
|
+
@user = User.new
|
10
|
+
@user_invitation = UserInvitation.find_by_token params[:token]
|
11
|
+
|
12
|
+
respond_to do |format|
|
13
|
+
if @user_invitation.nil?
|
14
|
+
format.html {redirect_to new_authentasaurus_session_path, :alert => t(:invalid_invitation_token, :scope => [:authentasaurus, :messages, :user_invitations])}
|
15
|
+
else
|
16
|
+
@user.email = @user_invitation.email
|
17
|
+
format.html
|
23
18
|
end
|
24
19
|
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def create
|
23
|
+
@user = User.new params[:user]
|
24
|
+
user_invitation = UserInvitation.find_by_token params[:token]
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
respond_to do |format|
|
31
|
-
unless user_invitation.nil?
|
32
|
-
if @user.save
|
33
|
-
format.html {redirect_to new_session_path}
|
34
|
-
else
|
35
|
-
format.html {render :new}
|
36
|
-
end
|
26
|
+
respond_to do |format|
|
27
|
+
unless user_invitation.nil?
|
28
|
+
if @user.save
|
29
|
+
format.html {redirect_to new_authentasaurus_session_path}
|
37
30
|
else
|
38
|
-
flash.now[:alert] = t(:invalid_invitation_token, :scope => [:authentasaurus, :messages, :user_invitations])
|
39
31
|
format.html {render :new}
|
40
32
|
end
|
33
|
+
else
|
34
|
+
flash.now[:alert] = t(:invalid_invitation_token, :scope => [:authentasaurus, :messages, :user_invitations])
|
35
|
+
format.html {render :new}
|
41
36
|
end
|
42
37
|
end
|
43
38
|
end
|
@@ -1,58 +1,57 @@
|
|
1
1
|
module Authentasaurus::Ac::Controllers
|
2
2
|
module SessionsController
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
base.send :before_filter, :check_is_logged_in, :except => [:destroy, :no_access]
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
before_filter :check_is_logged_in, :except => [:destroy, :no_access]
|
8
7
|
end
|
9
8
|
|
10
9
|
module ClassMethods
|
11
10
|
end
|
12
|
-
|
13
|
-
module InstanceMethods
|
14
|
-
def new
|
15
|
-
@session = Session.new
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
def new
|
13
|
+
@session = AuthentasaurusSession.new
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html
|
20
17
|
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def create
|
21
|
+
@session = AuthentasaurusSession.new params[:authentasaurus_session]
|
21
22
|
|
22
|
-
|
23
|
-
@session
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
session[:user_id] = @session.user.id
|
23
|
+
respond_to do |format|
|
24
|
+
if @session.save(self.class.user_model)
|
25
|
+
if @session.remember == "1"
|
26
|
+
cookies.signed.permanent[:remember_me_token] = @session.user.remember_me_token
|
27
|
+
end
|
28
|
+
session[:user_id] = @session.user.id
|
29
|
+
if @session.user.respond_to?(:permissions)
|
31
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}}
|
32
|
-
format.html { redirect_to session[:original_url] || (defined?(signin_redirect_path).nil? ? root_path : signin_redirect_path) }
|
33
|
-
else
|
34
|
-
format.html { render :action => :new }
|
35
31
|
end
|
32
|
+
format.html { redirect_to session[:original_url] || (defined?(authentasaurus_signin_redirect_path).nil? ? root_path : authentasaurus_signin_redirect_path) }
|
33
|
+
else
|
34
|
+
format.html { render :action => :new }
|
36
35
|
end
|
37
|
-
|
38
36
|
end
|
39
37
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
format.html { redirect_to :action => :new }
|
47
|
-
end
|
48
|
-
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy
|
41
|
+
session[:user_id] = nil
|
42
|
+
session[:user_permissions] = nil
|
43
|
+
cookies.delete :remember_me_token
|
49
44
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
45
|
+
respond_to do |format|
|
46
|
+
format.html { redirect_to :action => :new }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
def check_is_logged_in
|
52
|
+
if is_logged_in?
|
53
|
+
redirect_to defined?(authentasaurus_signin_redirect_path).nil? ? root_path : authentasaurus_signin_redirect_path
|
55
54
|
end
|
56
55
|
end
|
57
|
-
end
|
56
|
+
end
|
58
57
|
end
|
@@ -1,50 +1,45 @@
|
|
1
1
|
module Authentasaurus::Ac::Controllers
|
2
2
|
module UserInvitationsController
|
3
|
-
|
4
|
-
base.send :extend, ClassMethods
|
5
|
-
base.send :include, InstanceMethods
|
6
|
-
end
|
3
|
+
extend ActiveSupport::Concern
|
7
4
|
|
8
5
|
module ClassMethods
|
9
6
|
end
|
10
|
-
|
11
|
-
module InstanceMethods
|
12
|
-
def index
|
13
|
-
@invitations = UserInvitation.find :all
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
8
|
+
def index
|
9
|
+
@invitations = UserInvitation.find :all
|
19
10
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
respond_to do |format|
|
24
|
-
format.html
|
25
|
-
end
|
11
|
+
respond_to do |format|
|
12
|
+
format.html
|
26
13
|
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def new
|
17
|
+
@invitation = UserInvitation.new
|
27
18
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
respond_to do |format|
|
32
|
-
if @invitation.save
|
33
|
-
format.html { redirect_to :action => :index }
|
34
|
-
else
|
35
|
-
format.html {render :new}
|
36
|
-
end
|
37
|
-
end
|
19
|
+
respond_to do |format|
|
20
|
+
format.html
|
38
21
|
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def create
|
25
|
+
@invitation = UserInvitation.new params[:user_invitation]
|
39
26
|
|
40
|
-
|
41
|
-
invitation
|
42
|
-
invitation.destroy
|
43
|
-
|
44
|
-
respond_to do |format|
|
27
|
+
respond_to do |format|
|
28
|
+
if @invitation.save
|
45
29
|
format.html { redirect_to :action => :index }
|
30
|
+
else
|
31
|
+
format.html {render :new}
|
46
32
|
end
|
47
33
|
end
|
48
34
|
end
|
49
|
-
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
invitation = UserInvitation.find params[:id]
|
38
|
+
invitation.destroy
|
39
|
+
|
40
|
+
respond_to do |format|
|
41
|
+
format.html { redirect_to :action => :index }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
50
45
|
end
|
@@ -1,79 +1,74 @@
|
|
1
1
|
module Authentasaurus::Ac::Controllers
|
2
2
|
module UsersController
|
3
|
-
|
4
|
-
base.send :extend, ClassMethods
|
5
|
-
base.send :include, InstanceMethods
|
6
|
-
end
|
3
|
+
extend ActiveSupport::Concern
|
7
4
|
|
8
5
|
module ClassMethods
|
9
6
|
end
|
10
|
-
|
11
|
-
module InstanceMethods
|
12
|
-
def index
|
13
|
-
@users = User.all
|
14
7
|
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
def index
|
9
|
+
@users = User.all
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
format.html
|
18
13
|
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def show
|
17
|
+
@user = User.find(params[:id])
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
respond_to do |format|
|
24
|
-
format.html
|
25
|
-
end
|
19
|
+
respond_to do |format|
|
20
|
+
format.html
|
26
21
|
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def new
|
25
|
+
@user = User.new
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
respond_to do |format|
|
32
|
-
format.html
|
33
|
-
end
|
27
|
+
respond_to do |format|
|
28
|
+
format.html
|
34
29
|
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def create
|
33
|
+
@user = User.new params[:user]
|
35
34
|
|
36
|
-
|
37
|
-
@user
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
else
|
43
|
-
flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :users])
|
44
|
-
format.html { render :new }
|
45
|
-
end
|
35
|
+
respond_to do |format|
|
36
|
+
if @user.save
|
37
|
+
format.html { redirect_to :action=>:index, :notice => "User saved successfully" }
|
38
|
+
else
|
39
|
+
flash.now[:alert] = I18n.t(:create_failed, :scope => [:authentasaurus, :messages, :users])
|
40
|
+
format.html { render :new }
|
46
41
|
end
|
47
42
|
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def edit
|
46
|
+
@user = User.find params[:id]
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
respond_to do |format|
|
53
|
-
format.html
|
54
|
-
end
|
48
|
+
respond_to do |format|
|
49
|
+
format.html
|
55
50
|
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def update
|
54
|
+
@user = User.find params[:id]
|
56
55
|
|
57
|
-
|
58
|
-
@user
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
else
|
64
|
-
flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :users])
|
65
|
-
format.html { render :edit }
|
66
|
-
end
|
56
|
+
respond_to do |format|
|
57
|
+
if @user.update_attributes(params[:user])
|
58
|
+
format.html { redirect_to :action => :index, :notice => "User updated" }
|
59
|
+
else
|
60
|
+
flash.now[:alert] = I18n.t(:update_failed, :scope => [:authentasaurus, :messages, :users])
|
61
|
+
format.html { render :edit }
|
67
62
|
end
|
68
63
|
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def destroy
|
67
|
+
@user = User.find params[:id]
|
68
|
+
@user.destroy
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
@user.destroy
|
73
|
-
|
74
|
-
respond_to do |format|
|
75
|
-
format.html { redirect_to :action=>:index }
|
76
|
-
end
|
70
|
+
respond_to do |format|
|
71
|
+
format.html { redirect_to :action=>:index }
|
77
72
|
end
|
78
73
|
end
|
79
74
|
end
|