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.
- data/CHANGELIST +3 -0
- data/TODO +4 -4
- data/app/controllers/areas_controller.rb +2 -1
- data/app/controllers/groups_controller.rb +2 -1
- data/app/controllers/permissions_controller.rb +2 -1
- data/app/controllers/recoveries_controller.rb +2 -1
- data/app/controllers/registrations_controller.rb +2 -1
- data/app/controllers/sessions_controller.rb +2 -1
- data/app/controllers/user_invitations_controller.rb +2 -1
- data/app/controllers/users_controller.rb +2 -1
- data/app/controllers/validations_controller.rb +2 -1
- data/app/models/area.rb +2 -1
- data/app/models/group.rb +2 -1
- data/app/models/permission.rb +2 -1
- data/app/models/recovery.rb +2 -1
- data/app/models/session.rb +2 -1
- data/app/models/user_invitation.rb +2 -1
- data/app/models/validation.rb +2 -1
- data/lib/authentasaurus/areas_controller.rb +77 -68
- data/lib/authentasaurus/groups_controller.rb +78 -70
- data/lib/authentasaurus/models/area.rb +15 -6
- data/lib/authentasaurus/models/group.rb +15 -6
- data/lib/authentasaurus/models/permission.rb +19 -8
- data/lib/authentasaurus/models/recovery.rb +31 -21
- data/lib/authentasaurus/models/session.rb +59 -50
- data/lib/authentasaurus/models/user_invitation.rb +26 -16
- data/lib/authentasaurus/models/validation.rb +25 -15
- data/lib/authentasaurus/permissions_controller.rb +78 -69
- data/lib/authentasaurus/recoveries_controller.rb +62 -52
- data/lib/authentasaurus/registrations_controller.rb +34 -24
- data/lib/authentasaurus/sessions_controller.rb +42 -33
- data/lib/authentasaurus/user_invitations_controller.rb +36 -27
- data/lib/authentasaurus/users_controller.rb +77 -68
- data/lib/authentasaurus/validations_controller.rb +38 -28
- metadata +7 -6
- data/app/controllers/authentasaurus/authentasaurus_controller.rb +0 -2
@@ -1,60 +1,70 @@
|
|
1
|
-
|
2
|
-
def
|
3
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
-
|
2
|
-
def
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
13
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
36
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
12
|
-
|
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
|
-
|
15
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
36
|
-
|
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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|