mcms_authentication 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/ajax-loader.gif +0 -0
- data/app/assets/javascripts/application.js +2 -2
- data/app/assets/javascripts/validate_login.js +37 -0
- data/app/assets/stylesheets/authentication_global.css +1542 -319
- data/app/controllers/application_controller.rb +5 -2
- data/app/controllers/home_controller.rb +18 -1
- data/app/controllers/roles_controller.rb +17 -10
- data/app/controllers/users_controller.rb +89 -36
- data/app/models/user.rb +9 -4
- data/app/views/roles/_form.html.erb +18 -13
- data/app/views/roles/index.html.erb +61 -32
- data/app/views/users/confirmations/new.html.erb +1 -0
- data/app/views/users/edit.html.erb +26 -14
- data/app/views/users/first_user.html.erb +99 -0
- data/app/views/users/index.html.erb +65 -38
- data/app/views/users/new.html.erb +24 -10
- data/app/views/users/passwords/edit.html.erb +17 -1
- data/app/views/users/passwords/new.html.erb +18 -2
- data/app/views/users/sessions/new.html.erb +22 -29
- data/app/views/users/unlocks/new.html.erb +6 -6
- data/config/initializers/constants.rb +5 -6
- data/config/routes.rb +6 -2
- data/db/seeds.rb +0 -18
- data/lib/generators/mcms_authentication/mcms_authentication_generator.rb +38 -13
- data/lib/generators/mcms_authentication/templates/models.rb +16 -34
- data/lib/mcms_authentication/engine.rb +32 -3
- metadata +5 -10
- data/app/assets/javascripts/authentication_global.js +0 -17
- data/app/assets/stylesheets/application.css +0 -33
- data/app/views/layouts/users/_javascript.html.erb +0 -3
- data/app/views/layouts/users/_stylesheet.html.erb +0 -3
- data/app/views/layouts/users/devise.html.erb +0 -40
- data/app/views/layouts/users/home.html.erb +0 -99
- data/lib/mcms_authentication/seeds.rb +0 -14
- data/lib/tasks/mcms_authentication_tasks.rake +0 -4
@@ -33,18 +33,18 @@ class McmsAuthenticationGenerator < Rails::Generators::NamedBase
|
|
33
33
|
rake("mcms_authentication_engine:install:migrations")
|
34
34
|
|
35
35
|
# create file deb/seeds.rb to parent app if not exists
|
36
|
-
|
36
|
+
create_file "db/seeds.rb" unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
# append data to app's seeds.rb
|
39
|
+
append_file 'db/seeds.rb', :verbose => true do
|
40
40
|
|
41
|
-
|
41
|
+
<<-EOH
|
42
42
|
|
43
43
|
McmsAuthentication::Engine.load_seed
|
44
44
|
|
45
|
-
|
45
|
+
EOH
|
46
46
|
|
47
|
-
|
47
|
+
end # end block
|
48
48
|
|
49
49
|
end
|
50
50
|
|
@@ -63,24 +63,46 @@ class McmsAuthenticationGenerator < Rails::Generators::NamedBase
|
|
63
63
|
# @Purpose : Configurations are done here
|
64
64
|
|
65
65
|
def configure
|
66
|
+
original_app = File.binread("app/controllers/application_controller.rb")
|
66
67
|
|
67
|
-
|
68
|
+
if((original_app.include?("include ApplicationHelper")) && (original_app.include?("def after_sign_in_path_for(resource)")))
|
69
|
+
|
70
|
+
say_status("skipped", "insert into app/controllers/application_controller.rb", :yellow)
|
68
71
|
|
72
|
+
else
|
69
73
|
|
70
|
-
'
|
74
|
+
insert_into_file File.join('app/controllers', 'application_controller.rb'), :after => "ActionController::Base\n" do
|
75
|
+
|
76
|
+
|
77
|
+
'
|
71
78
|
include ApplicationHelper #including application_helper for the availability of filters
|
72
79
|
# The following snippet is responsible for rescuing from exception generated by CanCan gem
|
73
80
|
# for denying a particular module access with a notice to user and redirecting to root_url
|
74
81
|
rescue_from CanCan::AccessDenied do |exception|
|
75
82
|
|
76
83
|
flash[:error] = t(:access_denied,:default => "You are not authorized for doing this operation")
|
77
|
-
|
84
|
+
|
85
|
+
if Gem.available? ("mcms")
|
86
|
+
redirect_to "/mcms/dashboard"
|
87
|
+
else
|
88
|
+
"/"
|
89
|
+
end
|
78
90
|
|
79
91
|
end
|
80
92
|
|
93
|
+
def after_sign_in_path_for(resource)
|
94
|
+
if Gem.available? ("mcms")
|
95
|
+
"/mcms/dashboard" # <- Path you want to redirect the user to.
|
96
|
+
else
|
97
|
+
"/"
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
81
102
|
#end of configuration
|
82
103
|
|
83
|
-
|
104
|
+
'
|
105
|
+
end
|
84
106
|
end
|
85
107
|
|
86
108
|
end
|
@@ -91,10 +113,11 @@ class McmsAuthenticationGenerator < Rails::Generators::NamedBase
|
|
91
113
|
|
92
114
|
def prompt_user
|
93
115
|
|
94
|
-
|
116
|
+
unless Gem.available? ("mcms")
|
117
|
+
|
118
|
+
say "\ndon't forget to run the following \n
|
95
119
|
|
96
120
|
rake db:migrate\n
|
97
|
-
rake db:seed\n
|
98
121
|
|
99
122
|
in the controllers where you want to apply auth\n
|
100
123
|
|
@@ -103,8 +126,10 @@ class McmsAuthenticationGenerator < Rails::Generators::NamedBase
|
|
103
126
|
load_and_authorize_resource \n
|
104
127
|
|
105
128
|
Enjoy!\n\n"
|
106
|
-
|
129
|
+
end
|
130
|
+
|
107
131
|
end
|
108
132
|
|
133
|
+
|
109
134
|
|
110
135
|
end
|
@@ -1,35 +1,28 @@
|
|
1
1
|
=begin
|
2
|
-
*************************************************************************************************************
|
3
|
-
FileName: models.rb
|
4
2
|
|
5
|
-
|
3
|
+
@FileName: models.rb
|
6
4
|
|
7
|
-
|
5
|
+
@Company Name and Copyright information: Mindfire Solutions Pvt. Ltd.
|
8
6
|
|
9
|
-
|
7
|
+
@Creator name and date: Indranil Mukherjee 12/06/2012
|
10
8
|
|
11
|
-
|
12
|
-
=end
|
13
|
-
|
14
|
-
module Models
|
9
|
+
@Description of the file contents: Defining all the routes
|
15
10
|
|
16
|
-
=begin
|
17
11
|
|
18
|
-
|
19
|
-
|
20
|
-
The method is responsible for returning all existing models
|
12
|
+
=end
|
21
13
|
|
22
|
-
|
14
|
+
module Models
|
23
15
|
|
24
|
-
|
16
|
+
# @Params : Array
|
17
|
+
# @Returns : Array
|
18
|
+
# @Purpose : Returns array of existing models
|
25
19
|
|
26
|
-
|
27
20
|
def get_models
|
28
21
|
|
29
22
|
models = []
|
30
23
|
|
31
24
|
# @models = Dir[MODEL_DIR].map {|f| File.basename(f, '.*').camelize.constantize.name } # getting existing models
|
32
|
-
|
25
|
+
Rails.application.eager_load!
|
33
26
|
|
34
27
|
@models = ActiveRecord::Base.descendants.collect(&:name)
|
35
28
|
|
@@ -106,15 +99,9 @@ module Models
|
|
106
99
|
return arr
|
107
100
|
end
|
108
101
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
The method is responsible for defining a module based on the passed model and its association
|
114
|
-
|
115
|
-
returns modules as an array
|
116
|
-
|
117
|
-
=end
|
102
|
+
# @Params : Array
|
103
|
+
# @Returns : Array
|
104
|
+
# @Purpose : Returns array of interrelated models
|
118
105
|
|
119
106
|
def get_relations model
|
120
107
|
|
@@ -129,15 +116,10 @@ module Models
|
|
129
116
|
|
130
117
|
|
131
118
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
The method is responsible for defining a module name based on the passed models
|
137
|
-
|
138
|
-
returns a string
|
119
|
+
# @Params : Array
|
120
|
+
# @Returns : Array
|
121
|
+
# @Purpose : Returns determined name of the module
|
139
122
|
|
140
|
-
=end
|
141
123
|
|
142
124
|
|
143
125
|
def self.get_module_name(models)
|
@@ -1,15 +1,44 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
@File Name :mcms_authentication::engine.rb
|
4
|
+
|
5
|
+
@Company Name :Mindfire Solutions Pvt. Ltd.
|
6
|
+
|
7
|
+
@Creator Name :Indranil Mukherjee
|
8
|
+
|
9
|
+
@Date Created :2012-06-14
|
10
|
+
|
11
|
+
@Date Modified :2012-06-25
|
12
|
+
|
13
|
+
@Last Modification Details :Making it as mcms project standard
|
14
|
+
|
15
|
+
@Purpose :This file is responsible to install mcms_authentication module in other application/module
|
16
|
+
|
17
|
+
=end
|
18
|
+
|
1
19
|
module McmsAuthentication
|
2
20
|
class Engine < ::Rails::Engine
|
3
21
|
require 'devise'
|
4
22
|
require "cancan"
|
5
23
|
|
6
|
-
# Writting configurations
|
7
24
|
config.to_prepare do
|
25
|
+
|
26
|
+
if Gem.available?('mcms')
|
8
27
|
|
28
|
+
#if yes then use core layout
|
29
|
+
Devise::SessionsController.layout "mcms/main_layout"
|
30
|
+
Devise::PasswordsController.layout "mcms/main_layout"
|
31
|
+
|
32
|
+
elsif Gem.available?('mcms_pages')# if not
|
9
33
|
|
10
|
-
|
11
|
-
|
34
|
+
# use page's default layout
|
35
|
+
|
36
|
+
Devise::SessionsController.layout "mcms_pages/layouts/mcms_layout"
|
37
|
+
Devise::PasswordsController.layout "mcms_pages/layouts/mcms_layout"
|
38
|
+
|
39
|
+
end # end if
|
12
40
|
|
41
|
+
|
13
42
|
end
|
14
43
|
|
15
44
|
# Custom directories with classes and modules you want to be autoloadable.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcms_authentication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -68,10 +68,6 @@ extensions: []
|
|
68
68
|
extra_rdoc_files: []
|
69
69
|
files:
|
70
70
|
- app/views/home/index.html.erb
|
71
|
-
- app/views/layouts/users/_javascript.html.erb
|
72
|
-
- app/views/layouts/users/home.html.erb
|
73
|
-
- app/views/layouts/users/_stylesheet.html.erb
|
74
|
-
- app/views/layouts/users/devise.html.erb
|
75
71
|
- app/views/roles/new.html.erb
|
76
72
|
- app/views/roles/_form.js.erb
|
77
73
|
- app/views/roles/edit.html.erb
|
@@ -84,6 +80,7 @@ files:
|
|
84
80
|
- app/views/users/new.html.erb
|
85
81
|
- app/views/users/shared/_links.erb
|
86
82
|
- app/views/users/unlocks/new.html.erb
|
83
|
+
- app/views/users/first_user.html.erb
|
87
84
|
- app/views/users/edit.html.erb
|
88
85
|
- app/views/users/passwords/new.html.erb
|
89
86
|
- app/views/users/passwords/edit.html.erb
|
@@ -91,6 +88,7 @@ files:
|
|
91
88
|
- app/views/users/_role.js.erb
|
92
89
|
- app/views/users/confirmations/new.html.erb
|
93
90
|
- app/assets/images/rails.png
|
91
|
+
- app/assets/images/ajax-loader.gif
|
94
92
|
- app/assets/images/background/page_bg.png
|
95
93
|
- app/assets/images/background/text_field_background.png
|
96
94
|
- app/assets/images/icons/delete.png
|
@@ -100,8 +98,7 @@ files:
|
|
100
98
|
- app/assets/images/icons/email_go.png
|
101
99
|
- app/assets/images/icons/add.png
|
102
100
|
- app/assets/javascripts/application.js
|
103
|
-
- app/assets/javascripts/
|
104
|
-
- app/assets/stylesheets/application.css
|
101
|
+
- app/assets/javascripts/validate_login.js
|
105
102
|
- app/assets/stylesheets/authentication_global.css
|
106
103
|
- app/models/ability.rb
|
107
104
|
- app/models/existing_model.rb
|
@@ -127,8 +124,6 @@ files:
|
|
127
124
|
- db/seeds.rb
|
128
125
|
- lib/mcms_authentication/engine.rb
|
129
126
|
- lib/mcms_authentication/version.rb
|
130
|
-
- lib/mcms_authentication/seeds.rb
|
131
|
-
- lib/tasks/mcms_authentication_tasks.rake
|
132
127
|
- lib/mcms_authentication.rb
|
133
128
|
- lib/generators/mcms_authentication/templates/models.rb
|
134
129
|
- lib/generators/mcms_authentication/templates/asset_manager.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
|
3
|
-
@File Name :authentication_global.js
|
4
|
-
|
5
|
-
@Company Name :Mindfire Solutions Pvt. Ltd.
|
6
|
-
|
7
|
-
@Creator Name :Indranil Mukherjee
|
8
|
-
|
9
|
-
@Date Created :2012-06-04
|
10
|
-
|
11
|
-
@Date Modified :2012-06-15
|
12
|
-
|
13
|
-
@Last Modification Details :Making it as mcms project standard
|
14
|
-
|
15
|
-
@Purpose :Global js
|
16
|
-
|
17
|
-
*/
|
@@ -1,33 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
|
3
|
-
@File Name :application.css
|
4
|
-
|
5
|
-
@Company Name :Mindfire Solutions Pvt. Ltd.
|
6
|
-
|
7
|
-
@Creator Name :Indranil Mukherjee
|
8
|
-
|
9
|
-
@Date Created :2012-06-04
|
10
|
-
|
11
|
-
@Date Modified :2012-06-15
|
12
|
-
|
13
|
-
@Last Modification Details :Making it as mcms project standard
|
14
|
-
|
15
|
-
@Purpose :Default css
|
16
|
-
|
17
|
-
*/
|
18
|
-
|
19
|
-
/*
|
20
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
21
|
-
* listed below.
|
22
|
-
*
|
23
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
24
|
-
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
25
|
-
*
|
26
|
-
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
27
|
-
* compiled file, but it's generally better to create a new file per style scope.
|
28
|
-
*
|
29
|
-
* require_self
|
30
|
-
* require_tree .
|
31
|
-
|
32
|
-
*/
|
33
|
-
|
@@ -1,40 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
|
3
|
-
@File Name :devise.html.erb
|
4
|
-
|
5
|
-
@Company Name :Mindfire Solutions Pvt. Ltd.
|
6
|
-
|
7
|
-
@Creator Name :Indranil Mukherjee
|
8
|
-
|
9
|
-
@Date Created :2012-06-04
|
10
|
-
|
11
|
-
@Date Modified :2012-06-14
|
12
|
-
|
13
|
-
@Last Modification Details :Making it as mcms project standard
|
14
|
-
|
15
|
-
@Purpose :Main layout
|
16
|
-
|
17
|
-
-->
|
18
|
-
|
19
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
20
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
21
|
-
<html xmlns="http://www.w3.org/1999/xhtml">
|
22
|
-
<head>
|
23
|
-
|
24
|
-
<title>Mcms Authentication</title>
|
25
|
-
|
26
|
-
<%= stylesheet_link_tag "authentication_global", :media => "all" %>
|
27
|
-
|
28
|
-
<%= csrf_meta_tags %>
|
29
|
-
|
30
|
-
</head>
|
31
|
-
|
32
|
-
<body>
|
33
|
-
|
34
|
-
<%= yield %>
|
35
|
-
|
36
|
-
</body>
|
37
|
-
|
38
|
-
</html>
|
39
|
-
|
40
|
-
|
@@ -1,99 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
|
3
|
-
@File Name :home.html.erb
|
4
|
-
|
5
|
-
@Company Name :Mindfire Solutions Pvt. Ltd.
|
6
|
-
|
7
|
-
@Creator Name :Indranil Mukherjee
|
8
|
-
|
9
|
-
@Date Created :2012-06-04
|
10
|
-
|
11
|
-
@Date Modified :2012-06-14
|
12
|
-
|
13
|
-
@Last Modification Details :Making it as mcms project standard
|
14
|
-
|
15
|
-
@Purpose :Custom layout
|
16
|
-
|
17
|
-
-->
|
18
|
-
|
19
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
20
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
21
|
-
<html xmlns="http://www.w3.org/1999/xhtml">
|
22
|
-
|
23
|
-
<head>
|
24
|
-
|
25
|
-
<title>Mcms Authentication</title>
|
26
|
-
|
27
|
-
<!-- Following is the stylesheets included using rails helper stylesheet_link_tag -->
|
28
|
-
|
29
|
-
<%= stylesheet_link_tag "authentication_global", :media => "all" %>
|
30
|
-
|
31
|
-
<!-- Following is the javascripts included using rails helper javascript_include_tag -->
|
32
|
-
|
33
|
-
<%= javascript_include_tag "application","authentication_global" %>
|
34
|
-
|
35
|
-
|
36
|
-
<!-- ".ui.core","ui.widget","ui.tabs" are used for tabbed pane -->
|
37
|
-
<%= render :partial => "layouts/users/javascript" %>
|
38
|
-
<!-- This is to prevent from outside forgery -->
|
39
|
-
|
40
|
-
<%= csrf_meta_tags %>
|
41
|
-
|
42
|
-
<!-- specific pages needs some javascripts -->
|
43
|
-
|
44
|
-
<%= yield :javascript %>
|
45
|
-
|
46
|
-
</head>
|
47
|
-
|
48
|
-
<body>
|
49
|
-
|
50
|
-
<div id="header">
|
51
|
-
<div id="site-bar-branding">
|
52
|
-
<span id="site-bar-company_name">
|
53
|
-
MCMS Authentication
|
54
|
-
</span>
|
55
|
-
|
56
|
-
<% if user_signed_in? %> <!-- checking if any user logged in -->
|
57
|
-
|
58
|
-
<a id="logout" href="<%= mcms_users_logout_path %>">Log out</a>
|
59
|
-
|
60
|
-
<% end %>
|
61
|
-
|
62
|
-
</div>
|
63
|
-
</div>
|
64
|
-
<% if flash[:notice] || flash[:error] %> <!-- If any notice or errors are there -->
|
65
|
-
|
66
|
-
<div id="flash-container">
|
67
|
-
|
68
|
-
|
69
|
-
<div style="visibility: visible; opacity: 1;" class="flash flash-notice" id="flash">
|
70
|
-
|
71
|
-
<%= flash[:notice] || flash[:error] %>
|
72
|
-
|
73
|
-
<a id="flash-close" href="">Close</a>
|
74
|
-
|
75
|
-
</div>
|
76
|
-
|
77
|
-
</div>
|
78
|
-
|
79
|
-
<% end %>
|
80
|
-
|
81
|
-
<div id="tabs">
|
82
|
-
|
83
|
-
<ul>
|
84
|
-
|
85
|
-
<li data-path="/mcms/users"><a id="users" href="/mcms/users" style="cursor: pointer;">Users</a></li>
|
86
|
-
|
87
|
-
<li data-path="/mcms/roles" ><a id="roles" href="/mcms/roles" style="cursor: pointer">Roles</a></li>
|
88
|
-
|
89
|
-
</ul>
|
90
|
-
|
91
|
-
</div>
|
92
|
-
|
93
|
-
<!-- yielding from views -->
|
94
|
-
|
95
|
-
<%= yield %>
|
96
|
-
|
97
|
-
</body>
|
98
|
-
|
99
|
-
</html>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#default data for mcms_authentication
|
2
|
-
|
3
|
-
User.create!(:email => "admin@mcms.com" ,:password => "admin123" )
|
4
|
-
Role.create!(:title => 'superuser')
|
5
|
-
|
6
|
-
u = User.find_by_email('admin@mcms.com')
|
7
|
-
|
8
|
-
r = Role.find_by_title('superuser')
|
9
|
-
|
10
|
-
RolesUser.create!(:user_id => u.id , :role_id => r.id) #writting seeds
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|