simple_user 0.1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +35 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/simple_user/application.js +15 -0
- data/app/assets/javascripts/simple_user/facebook_connect.js.erb +33 -0
- data/app/assets/stylesheets/simple_user/application.css +13 -0
- data/app/controllers/simple_user/admin_users/registrations_controller.rb +7 -0
- data/app/controllers/simple_user/admin_users/sessions_controller.rb +20 -0
- data/app/controllers/simple_user/admin_users_controller.rb +134 -0
- data/app/controllers/simple_user/application_controller.rb +7 -0
- data/app/controllers/simple_user/auth_controller.rb +26 -0
- data/app/controllers/simple_user/users/registrations_controller.rb +5 -0
- data/app/controllers/simple_user/users/sessions_controller.rb +41 -0
- data/app/controllers/simple_user/users_controller.rb +88 -0
- data/app/helpers/simple_user/application_helper.rb +13 -0
- data/app/helpers/simple_user/links_helper.rb +9 -0
- data/app/models/ability.rb +25 -0
- data/app/models/role.rb +18 -0
- data/app/models/simple_user/admin_user.rb +48 -0
- data/app/models/simple_user/authentication.rb +9 -0
- data/app/models/simple_user/user.rb +92 -0
- data/app/views/layouts/simple_user/application.html.erb +28 -0
- data/app/views/simple_user/admin_users/_form.html.erb +15 -0
- data/app/views/simple_user/admin_users/confirmations/new.html.erb +16 -0
- data/app/views/simple_user/admin_users/edit.html.erb +6 -0
- data/app/views/simple_user/admin_users/index.html.erb +27 -0
- data/app/views/simple_user/admin_users/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/simple_user/admin_users/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/simple_user/admin_users/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/simple_user/admin_users/new.html.erb +5 -0
- data/app/views/simple_user/admin_users/passwords/edit.html.erb +19 -0
- data/app/views/simple_user/admin_users/passwords/new.html.erb +15 -0
- data/app/views/simple_user/admin_users/registrations/edit.html.erb +28 -0
- data/app/views/simple_user/admin_users/registrations/new.html.erb +18 -0
- data/app/views/simple_user/admin_users/sessions/new.html.erb +15 -0
- data/app/views/simple_user/admin_users/shared/_links.erb +25 -0
- data/app/views/simple_user/admin_users/show.html.erb +15 -0
- data/app/views/simple_user/admin_users/unlocks/new.html.erb +16 -0
- data/app/views/simple_user/application/_menu_admin_users.html.erb +15 -0
- data/app/views/simple_user/application/_menu_users.html.erb +9 -0
- data/app/views/simple_user/users/_form.html.erb +14 -0
- data/app/views/simple_user/users/confirmations/new.html.erb +16 -0
- data/app/views/simple_user/users/edit.html.erb +6 -0
- data/app/views/simple_user/users/index.html.erb +31 -0
- data/app/views/simple_user/users/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/simple_user/users/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/simple_user/users/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/simple_user/users/new.html.erb +5 -0
- data/app/views/simple_user/users/passwords/edit.html.erb +19 -0
- data/app/views/simple_user/users/passwords/new.html.erb +15 -0
- data/app/views/simple_user/users/registrations/edit.html.erb +30 -0
- data/app/views/simple_user/users/registrations/new.html.erb +20 -0
- data/app/views/simple_user/users/sessions/new.html.erb +15 -0
- data/app/views/simple_user/users/shared/_links.erb +25 -0
- data/app/views/simple_user/users/show.html.erb +25 -0
- data/app/views/simple_user/users/unlocks/new.html.erb +16 -0
- data/config/initializers/devise.rb +243 -0
- data/config/initializers/omniauth.rb +7 -0
- data/config/initializers/rolify.rb +8 -0
- data/config/locales/devise.en.yml +59 -0
- data/config/routes.rb +39 -0
- data/db/migrate/20130312215459_devise_create_simple_user_users.rb +50 -0
- data/db/migrate/20130312215519_devise_create_simple_user_admin_users.rb +48 -0
- data/db/migrate/20130312215950_create_simple_user_authentications.rb +13 -0
- data/db/migrate/20130312226960_rolify_create_roles.rb +19 -0
- data/db/seed.rb +9 -0
- data/lib/generators/simple_user/generate_views/generate_views_generator.rb +12 -0
- data/lib/generators/simple_user/install/install_generator.rb +20 -0
- data/lib/generators/simple_user/install/templates/devise_config.yml +1 -0
- data/lib/generators/simple_user/install/templates/fb_config.yml +3 -0
- data/lib/generators/simple_user/install/templates/simple_user.yml +3 -0
- data/lib/simple_user.rb +4 -0
- data/lib/simple_user/engine.rb +48 -0
- data/lib/simple_user/version.rb +3 -0
- data/lib/tasks/simple_user_tasks.rake +16 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +16 -0
- data/test/dummy/app/assets/javascripts/welcome.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/welcome.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +31 -0
- data/test/dummy/app/controllers/welcome_controller.rb +4 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/welcome_helper.rb +2 -0
- data/test/dummy/app/views/admin_users/_form.html.erb +15 -0
- data/test/dummy/app/views/admin_users/confirmations/new.html.erb +16 -0
- data/test/dummy/app/views/admin_users/edit.html.erb +6 -0
- data/test/dummy/app/views/admin_users/index.html.erb +27 -0
- data/test/dummy/app/views/admin_users/mailer/confirmation_instructions.html.erb +5 -0
- data/test/dummy/app/views/admin_users/mailer/reset_password_instructions.html.erb +8 -0
- data/test/dummy/app/views/admin_users/mailer/unlock_instructions.html.erb +7 -0
- data/test/dummy/app/views/admin_users/new.html.erb +5 -0
- data/test/dummy/app/views/admin_users/passwords/edit.html.erb +19 -0
- data/test/dummy/app/views/admin_users/passwords/new.html.erb +15 -0
- data/test/dummy/app/views/admin_users/registrations/edit.html.erb +28 -0
- data/test/dummy/app/views/admin_users/registrations/new.html.erb +18 -0
- data/test/dummy/app/views/admin_users/sessions/new.html.erb +15 -0
- data/test/dummy/app/views/admin_users/shared/_links.erb +25 -0
- data/test/dummy/app/views/admin_users/show.html.erb +15 -0
- data/test/dummy/app/views/admin_users/unlocks/new.html.erb +16 -0
- data/test/dummy/app/views/application/_menu_admin_users.html.erb +15 -0
- data/test/dummy/app/views/application/_menu_users.html.erb +9 -0
- data/test/dummy/app/views/layouts/application.html.erb +28 -0
- data/test/dummy/app/views/simple_user/admin_users/_form.html.erb +15 -0
- data/test/dummy/app/views/simple_user/admin_users/confirmations/new.html.erb +16 -0
- data/test/dummy/app/views/simple_user/admin_users/edit.html.erb +6 -0
- data/test/dummy/app/views/simple_user/admin_users/index.html.erb +27 -0
- data/test/dummy/app/views/simple_user/admin_users/mailer/confirmation_instructions.html.erb +5 -0
- data/test/dummy/app/views/simple_user/admin_users/mailer/reset_password_instructions.html.erb +8 -0
- data/test/dummy/app/views/simple_user/admin_users/mailer/unlock_instructions.html.erb +7 -0
- data/test/dummy/app/views/simple_user/admin_users/new.html.erb +5 -0
- data/test/dummy/app/views/simple_user/admin_users/passwords/edit.html.erb +19 -0
- data/test/dummy/app/views/simple_user/admin_users/passwords/new.html.erb +15 -0
- data/test/dummy/app/views/simple_user/admin_users/registrations/edit.html.erb +28 -0
- data/test/dummy/app/views/simple_user/admin_users/registrations/new.html.erb +18 -0
- data/test/dummy/app/views/simple_user/admin_users/sessions/new.html.erb +15 -0
- data/test/dummy/app/views/simple_user/admin_users/shared/_links.erb +25 -0
- data/test/dummy/app/views/simple_user/admin_users/show.html.erb +15 -0
- data/test/dummy/app/views/simple_user/admin_users/unlocks/new.html.erb +16 -0
- data/test/dummy/app/views/simple_user/application/_menu_admin_users.html.erb +15 -0
- data/test/dummy/app/views/simple_user/application/_menu_users.html.erb +9 -0
- data/test/dummy/app/views/simple_user/users/_form.html.erb +14 -0
- data/test/dummy/app/views/simple_user/users/confirmations/new.html.erb +16 -0
- data/test/dummy/app/views/simple_user/users/edit.html.erb +6 -0
- data/test/dummy/app/views/simple_user/users/index.html.erb +31 -0
- data/test/dummy/app/views/simple_user/users/mailer/confirmation_instructions.html.erb +5 -0
- data/test/dummy/app/views/simple_user/users/mailer/reset_password_instructions.html.erb +8 -0
- data/test/dummy/app/views/simple_user/users/mailer/unlock_instructions.html.erb +7 -0
- data/test/dummy/app/views/simple_user/users/new.html.erb +5 -0
- data/test/dummy/app/views/simple_user/users/passwords/edit.html.erb +19 -0
- data/test/dummy/app/views/simple_user/users/passwords/new.html.erb +15 -0
- data/test/dummy/app/views/simple_user/users/registrations/edit.html.erb +30 -0
- data/test/dummy/app/views/simple_user/users/registrations/new.html.erb +20 -0
- data/test/dummy/app/views/simple_user/users/sessions/new.html.erb +15 -0
- data/test/dummy/app/views/simple_user/users/shared/_links.erb +25 -0
- data/test/dummy/app/views/simple_user/users/show.html.erb +25 -0
- data/test/dummy/app/views/simple_user/users/unlocks/new.html.erb +16 -0
- data/test/dummy/app/views/welcome/index.html.erb +3 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/devise_config.yml +1 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/fb_config.yml +3 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +7 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130314021609_devise_create_simple_user_users.simple_user.rb +51 -0
- data/test/dummy/db/migrate/20130314021610_devise_create_simple_user_admin_users.simple_user.rb +49 -0
- data/test/dummy/db/migrate/20130314021611_create_simple_user_authentications.simple_user.rb +14 -0
- data/test/dummy/db/migrate/20130314021612_rolify_create_simple_user_roles.simple_user.rb +20 -0
- data/test/dummy/db/migrate/20130314222446_devise_create_simple_user_users.simple_user.rb +51 -0
- data/test/dummy/db/migrate/20130314222447_devise_create_simple_user_admin_users.simple_user.rb +49 -0
- data/test/dummy/db/migrate/20130314222448_create_simple_user_authentications.simple_user.rb +14 -0
- data/test/dummy/db/migrate/20130314222449_rolify_create_roles.simple_user.rb +20 -0
- data/test/dummy/db/schema.rb +87 -0
- data/test/dummy/log/development.log +100 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/functional/welcome_controller_test.rb +9 -0
- data/test/dummy/test/unit/helpers/welcome_helper_test.rb +4 -0
- data/test/dummy/tmp/cache/assets/C43/6A0/sprockets%2F9112a8a5c58f114023075f00ab994366 +0 -0
- data/test/dummy/tmp/cache/assets/C7B/190/sprockets%2F37b103f4623089af1456b90830fe941c +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/D13/C60/sprockets%2F2dedb8177c20286c4259c1d58c5646cc +0 -0
- data/test/dummy/tmp/cache/assets/D21/5D0/sprockets%2Fe2c4f946939f2d7d0b42d86383755cae +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D3E/F40/sprockets%2F25a167c7563d6fe8ec6b13ec1ac09274 +0 -0
- data/test/dummy/tmp/cache/assets/D43/A50/sprockets%2Fa41b368b71464f0a4feb19b6f875e44e +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D92/950/sprockets%2Fcda629d2e4e4583027facd41bf1ea406 +0 -0
- data/test/dummy/tmp/cache/assets/DA0/140/sprockets%2F25f485eb0a9f28b68e69ab1c0f57c0da +0 -0
- data/test/dummy/tmp/cache/assets/DCF/BD0/sprockets%2Fc8b53c6aae12e5a5be5fe8db5472a793 +0 -0
- data/test/dummy/tmp/cache/assets/DD2/810/sprockets%2Fdc8aca3689d6b6e14aa38b7c88a46bc3 +0 -0
- data/test/dummy/tmp/cache/assets/DD8/CE0/sprockets%2F5de7f141c1d9dc26ce8af1ad6246d99f +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/E02/930/sprockets%2Fec83bf6c33e43fb6a5cf38a52df8c60e +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E2A/CE0/sprockets%2F17bd5e2fd8a5fd2d834c9dadfd102c2f +0 -0
- data/test/fixtures/simple_user/admin_users.yml +11 -0
- data/test/fixtures/simple_user/authentications.yml +13 -0
- data/test/fixtures/simple_user/users.yml +11 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/simple_user_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/simple_user/admin_user_test.rb +9 -0
- data/test/unit/simple_user/authentication_test.rb +9 -0
- data/test/unit/simple_user/user_test.rb +9 -0
- metadata +516 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
class Ability
|
2
|
+
include CanCan::Ability
|
3
|
+
|
4
|
+
def initialize(admin_user)
|
5
|
+
admin_user ||= SimpleUser::AdminUser.new
|
6
|
+
|
7
|
+
puts "ADMIN USER: #{admin_user.inspect}"
|
8
|
+
|
9
|
+
if admin_user.has_role? :admin
|
10
|
+
can :manage, :all
|
11
|
+
else
|
12
|
+
if admin_user.has_role? :role_manager
|
13
|
+
can :manage, SimpleUser::AdminUser
|
14
|
+
can :manage, Role
|
15
|
+
elsif admin_user.has_role? :admin_user_manager
|
16
|
+
can :manage, SimpleUser::AdminUser
|
17
|
+
end
|
18
|
+
|
19
|
+
if admin_user.has_role? :user_manager
|
20
|
+
can :manage, SimpleUser::User
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/app/models/role.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class Role < ActiveRecord::Base
|
2
|
+
|
3
|
+
=begin
|
4
|
+
has_and_belongs_to_many :simple_user_admin_users,
|
5
|
+
:class_name => "AdminUser",
|
6
|
+
:join_table => :simple_user_users_roles,
|
7
|
+
:foreign_key => :simple_user_role_id
|
8
|
+
#:association_foreign_key => "simple_user_admin_user_id"
|
9
|
+
=end
|
10
|
+
|
11
|
+
|
12
|
+
has_and_belongs_to_many :admin_users, :join_table => "users_roles"
|
13
|
+
|
14
|
+
belongs_to :resource, :polymorphic => true
|
15
|
+
|
16
|
+
scopify
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module SimpleUser
|
2
|
+
class AdminUser < ActiveRecord::Base
|
3
|
+
|
4
|
+
rolify
|
5
|
+
#resourcify
|
6
|
+
|
7
|
+
#has_and_belongs_to_many :roles, :join_table => :users_roles, :foreign_key => "user_id"
|
8
|
+
#has_many :simple_user_users_roles, :foreign_key => :user_id
|
9
|
+
#has_and_belongs_to_many :simple_user_roles, :join_table => :simple_user_users_roles
|
10
|
+
|
11
|
+
#has_and_belongs_to_many :roles, :join_table => :simple_user_users_roles
|
12
|
+
=begin
|
13
|
+
has_and_belongs_to_many :simple_user_roles,
|
14
|
+
:class_name => "Role",
|
15
|
+
:join_table => :simple_user_users_roles,
|
16
|
+
:foreign_key => :simple_user_admin_user_id
|
17
|
+
=end
|
18
|
+
#has_and_belongs_to_many :simple_user_admin_users, :join_table => :simple_user_users_roles
|
19
|
+
has_and_belongs_to_many :roles, :join_table => "users_roles", :foreign_key => :simple_user_admin_user_id
|
20
|
+
|
21
|
+
# Include default devise modules. Others available are:
|
22
|
+
# :token_authenticatable, :confirmable,
|
23
|
+
# :lockable, :timeoutable and :omniauthable
|
24
|
+
devise :database_authenticatable, :registerable,
|
25
|
+
:recoverable, :rememberable, :trackable, :validatable
|
26
|
+
|
27
|
+
# Setup accessible (or protected) attributes for your model
|
28
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :active
|
29
|
+
attr_accessible :temporal_roles
|
30
|
+
attr_accessor :temporal_roles
|
31
|
+
|
32
|
+
validates :email, :uniqueness => true
|
33
|
+
validates :username, :uniqueness => true
|
34
|
+
|
35
|
+
def get_roles
|
36
|
+
@temporal_roles = roles.collect{ |role| role.name }.join(", ")
|
37
|
+
end
|
38
|
+
|
39
|
+
def banned?
|
40
|
+
!active
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.get_editable_admins_except(admin_id)
|
44
|
+
joins(:roles).where("roles.name <> ? AND simple_user_admin_users.id <> ?", "admin", admin_id).group(:id)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module SimpleUser
|
2
|
+
class User < ActiveRecord::Base
|
3
|
+
|
4
|
+
resourcify
|
5
|
+
|
6
|
+
has_many :authentications, :dependent => :delete_all
|
7
|
+
|
8
|
+
# Include default devise modules. Others available are:
|
9
|
+
# :token_authenticatable, :confirmable,
|
10
|
+
# :lockable, :timeoutable and :omniauthable
|
11
|
+
devise :database_authenticatable, :registerable,
|
12
|
+
:recoverable, :rememberable, :trackable, :validatable
|
13
|
+
|
14
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :first_name, :last_name, :active
|
15
|
+
|
16
|
+
validates :email, :uniqueness => true
|
17
|
+
validates :username, :uniqueness => true
|
18
|
+
|
19
|
+
def self.build_new_auth(auth)
|
20
|
+
email = ""
|
21
|
+
|
22
|
+
if auth['provider'] == 'facebook'
|
23
|
+
user = User.find_by_email(auth['extra']['raw_info']['email'])
|
24
|
+
end
|
25
|
+
|
26
|
+
user ||= User.new
|
27
|
+
user.apply_omniauth(auth)
|
28
|
+
return user
|
29
|
+
end
|
30
|
+
|
31
|
+
def apply_omniauth(auth)
|
32
|
+
#Generates random usernames and passwords for the first time
|
33
|
+
if self.id.nil?
|
34
|
+
tmp_password = generate_random(8)
|
35
|
+
tmp_username = generate_random(6)
|
36
|
+
end
|
37
|
+
|
38
|
+
#Gets AUTH information
|
39
|
+
if auth['provider'] == 'facebook'
|
40
|
+
#Saves username and email for the first time
|
41
|
+
if self.id.nil?
|
42
|
+
tmp_username = auth['extra']['raw_info']['username'] rescue generate_random(6)
|
43
|
+
self.email = auth['extra']['raw_info']['email']
|
44
|
+
end
|
45
|
+
|
46
|
+
self.first_name = auth['extra']['raw_info']['first_name'] if self.first_name.nil?
|
47
|
+
self.last_name = auth['extra']['raw_info']['last_name'] if self.last_name.nil?
|
48
|
+
end
|
49
|
+
|
50
|
+
#Check if the username exists in the database and if it exists replace it with a new one, for the first time
|
51
|
+
if self.id.nil?
|
52
|
+
invalid_username = true
|
53
|
+
|
54
|
+
while invalid_username
|
55
|
+
tmp_user = User.find_by_username(tmp_username) rescue nil
|
56
|
+
if tmp_user.nil?
|
57
|
+
invalid_username = false
|
58
|
+
else
|
59
|
+
tmp_username = generate_random(6)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
#Sets main values for the first time
|
65
|
+
if self.id.nil?
|
66
|
+
self.username = tmp_username
|
67
|
+
self.password = tmp_password
|
68
|
+
self.password_confirmation = tmp_password
|
69
|
+
end
|
70
|
+
|
71
|
+
#Saves the authentication
|
72
|
+
authentications.build(:provider => auth['provider'], :uid => auth['uid'], :token => auth['credentials']['token'])
|
73
|
+
end
|
74
|
+
|
75
|
+
def full_name
|
76
|
+
first_name.to_s + " " + last_name.to_s
|
77
|
+
end
|
78
|
+
|
79
|
+
def banned?
|
80
|
+
!active
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
def generate_random(str_length)
|
85
|
+
charlist = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
86
|
+
generate_str = ""
|
87
|
+
1.upto(str_length) {|i| generate_str << charlist[rand(charlist.size-1)]}
|
88
|
+
return generate_str
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>SimpleUser</title>
|
5
|
+
<%= stylesheet_link_tag "application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
|
10
|
+
<body>
|
11
|
+
<div>
|
12
|
+
<%= render "menu_users" %> || <%= render "menu_admin_users" %>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<div>
|
16
|
+
<% flash.each do |name, msg| %>
|
17
|
+
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
|
18
|
+
<a class="close" data-dismiss="alert">×</a>
|
19
|
+
<%= msg %>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div>
|
25
|
+
<%= yield %>
|
26
|
+
</div>
|
27
|
+
</body>
|
28
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= simple_form_for @admin_user, :html => { :class => 'form-horizontal' } do |f| %>
|
2
|
+
<%= f.input :username, :required => true %>
|
3
|
+
<%= f.input :email, :required => true %>
|
4
|
+
<%= f.input :password, :required => @required_password %>
|
5
|
+
<%= f.input :password_confirmation, :required => @required_password %>
|
6
|
+
|
7
|
+
<% if can? :manage, Role %>
|
8
|
+
<%= f.input :temporal_roles, :label => "Roles" %>
|
9
|
+
<%= f.input :active %>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<div class="actions">
|
13
|
+
<%= f.button :submit %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<h2>Resend confirmation instructions</h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
|
4
|
+
<%= f.error_notification %>
|
5
|
+
<%= f.full_error :confirmation_token %>
|
6
|
+
|
7
|
+
<div class="form-inputs">
|
8
|
+
<%= f.input :email, :required => true, :autofocus => true %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="form-actions">
|
12
|
+
<%= f.button :submit, "Resend confirmation instructions" %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= render "devise/shared/links" %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<h1>Administrators</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th>Email</th>
|
6
|
+
<th>Username</th>
|
7
|
+
<th>Active</th>
|
8
|
+
<th></th>
|
9
|
+
<th></th>
|
10
|
+
<th></th>
|
11
|
+
</tr>
|
12
|
+
|
13
|
+
<% @admin_users.each do |admin_user| %>
|
14
|
+
<tr>
|
15
|
+
<td><%= admin_user.email %></td>
|
16
|
+
<td><%= admin_user.username %></td>
|
17
|
+
<td><%= print_yes_or_no admin_user.active %></td>
|
18
|
+
<td><%= link_to 'Show', admin_user %></td>
|
19
|
+
<td><%= link_to 'Edit', edit_admin_user_path(admin_user) %></td>
|
20
|
+
<td><%= link_to 'Destroy', admin_user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
21
|
+
</tr>
|
22
|
+
<% end %>
|
23
|
+
</table>
|
24
|
+
|
25
|
+
<br />
|
26
|
+
|
27
|
+
<%= link_to 'New Admin user', new_admin_user_path %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<p>Hello <%= @resource.email %>!</p>
|
2
|
+
|
3
|
+
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
|
4
|
+
|
5
|
+
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
|
6
|
+
|
7
|
+
<p>If you didn't request this, please ignore this email.</p>
|
8
|
+
<p>Your password won't change until you access the link above and create a new one.</p>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p>Hello <%= @resource.email %>!</p>
|
2
|
+
|
3
|
+
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
|
4
|
+
|
5
|
+
<p>Click the link below to unlock your account:</p>
|
6
|
+
|
7
|
+
<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h2>Change your password</h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
|
4
|
+
<%= f.error_notification %>
|
5
|
+
|
6
|
+
<%= f.input :reset_password_token, :as => :hidden %>
|
7
|
+
<%= f.full_error :reset_password_token %>
|
8
|
+
|
9
|
+
<div class="form-inputs">
|
10
|
+
<%= f.input :password, :label => "New password", :required => true, :autofocus => true %>
|
11
|
+
<%= f.input :password_confirmation, :label => "Confirm your new password", :required => true %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div class="form-actions">
|
15
|
+
<%= f.button :submit, "Change my password" %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= render "devise/shared/links" %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<h2>Forgot your password?</h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
|
4
|
+
<%= f.error_notification %>
|
5
|
+
|
6
|
+
<div class="form-inputs">
|
7
|
+
<%= f.input :email, :required => true, :autofocus => true %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="form-actions">
|
11
|
+
<%= f.button :submit, "Send me reset password instructions" %>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<%= render "devise/shared/links" %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
4
|
+
<%= f.error_notification %>
|
5
|
+
|
6
|
+
<div class="form-inputs">
|
7
|
+
<%= f.input :username, :required => true, :autofocus => true %>
|
8
|
+
<%= f.input :email, :required => true, :autofocus => true %>
|
9
|
+
|
10
|
+
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
11
|
+
<p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= f.input :password, :autocomplete => "off", :hint => "leave it blank if you don't want to change it", :required => false %>
|
15
|
+
<%= f.input :password_confirmation, :required => false %>
|
16
|
+
<%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="form-actions">
|
20
|
+
<%= f.button :submit, "Update" %>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<h3>Cancel my account</h3>
|
25
|
+
|
26
|
+
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.</p>
|
27
|
+
|
28
|
+
<%= link_to "Back", :back %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<h2>Sign up</h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
|
4
|
+
<%= f.error_notification %>
|
5
|
+
|
6
|
+
<div class="form-inputs">
|
7
|
+
<%= f.input :username, :required => true, :autofocus => true %>
|
8
|
+
<%= f.input :email, :required => true, :autofocus => true %>
|
9
|
+
<%= f.input :password, :required => true %>
|
10
|
+
<%= f.input :password_confirmation, :required => true %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="form-actions">
|
14
|
+
<%= f.button :submit, "Sign up" %>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<%= render "devise/shared/links" %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<h2>Sign in</h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
4
|
+
<div class="form-inputs">
|
5
|
+
<%= f.input :username, :required => true, :autofocus => true %>
|
6
|
+
<%= f.input :password, :required => true %>
|
7
|
+
<%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="form-actions">
|
11
|
+
<%= f.button :submit, "Sign in" %>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<%= render "devise/shared/links" %>
|