optimacms 0.1.5 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/optimacms/admin/admin_base_controller.rb +13 -0
  3. data/app/controllers/optimacms/admin/templates_controller.rb +5 -1
  4. data/app/controllers/optimacms/dev_controller.rb +11 -0
  5. data/app/helpers/optimacms/application_helper.rb +2 -1
  6. data/app/models/optimacms/cms_admin_user.rb +10 -0
  7. data/app/views/cms_admin_users/confirmations/new.html.erb +16 -0
  8. data/app/views/cms_admin_users/mailer/confirmation_instructions.html.erb +5 -0
  9. data/app/views/cms_admin_users/mailer/reset_password_instructions.html.erb +8 -0
  10. data/app/views/cms_admin_users/mailer/unlock_instructions.html.erb +7 -0
  11. data/app/views/cms_admin_users/passwords/edit.html.erb +22 -0
  12. data/app/views/cms_admin_users/passwords/new.html.erb +16 -0
  13. data/app/views/cms_admin_users/registrations/edit.html.erb +39 -0
  14. data/app/views/cms_admin_users/registrations/new.html.erb +29 -0
  15. data/app/views/cms_admin_users/sessions/new.html.erb +26 -0
  16. data/app/views/cms_admin_users/shared/_links.html.erb +25 -0
  17. data/app/views/cms_admin_users/unlocks/new.html.erb +16 -0
  18. data/app/views/layouts/optimacms/application_logged_out.html.erb +15 -0
  19. data/app/views/optimacms/admin/shared/_top.html.haml +9 -1
  20. data/config/locales/devise.en.yml +60 -0
  21. data/config/routes.rb +2 -1
  22. data/db/migrate/20150503213839_devise_create_optimacms_cms_users.rb +42 -0
  23. data/lib/optimacms/devise.rb +88 -0
  24. data/lib/optimacms/engine.rb +1 -0
  25. data/lib/optimacms/version.rb +1 -1
  26. data/lib/optimacms.rb +1 -0
  27. data/test/dummy/app/models/user.rb +6 -0
  28. data/test/dummy/app/views/home/index.html.haml +4 -0
  29. data/test/dummy/config/initializers/devise.rb +259 -0
  30. data/test/dummy/config/locales/devise.en.yml +60 -0
  31. data/test/dummy/config/routes.rb +9 -0
  32. data/test/dummy/db/migrate/20150504000518_devise_create_users.rb +42 -0
  33. data/test/dummy/db/schema.rb +84 -43
  34. data/test/dummy/log/development.log +7466 -0
  35. data/test/dummy/spec/factories/users.rb +6 -0
  36. data/test/dummy/spec/models/user_spec.rb +5 -0
  37. data/test/dummy/tmp/pids/server.pid +1 -1
  38. data/test/fixtures/optimacms/cms_users.yml +11 -0
  39. data/test/models/optimacms/cms_user_test.rb +9 -0
  40. metadata +48 -3
  41. data/app/models/optimacms/article.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7423961f90b9cefc9804eba62c7a24a34ab07cb5
4
- data.tar.gz: c5db0f9c93e7397db548504094fbd9d038a7c1a7
3
+ metadata.gz: edd2451b5701cc30dff19fe4e8587ec829b713df
4
+ data.tar.gz: f7ca96f3f0b8250167a21af1bdac307d9a19b1cd
5
5
  SHA512:
6
- metadata.gz: ae063cca5a45779f75f469eb98c16fa9f443261b066c7797b8c588b7bc128ebda303d4006cc2f5a1c4b5e70d96f0fc68d3e3ab744250b56498f864eec260b184
7
- data.tar.gz: 5b36846f5bd8ba734bd139184291708f0dda10bb16200a9eb41092ef379597a876a413d49ca22dbde5e62c7a57b83682780d971dbbb5e92230be2001583eed98
6
+ metadata.gz: c9b95dead01c57644d03843e1c50702a0eceb6682d2d02d62b1ceac9f7a14de2f4f66607ddd1b917c4ea486c5755f7e300b67a0d4f4635cef4911329de82dfea
7
+ data.tar.gz: 0006fd2078b9156e88be5fa708638bb60eb9da7e0d3a6f9457407c24eff9e329a497c3cc893fb8f21f7c89b18f9bfbb0b5048dd3b547d6d1825d315db7bc634b
@@ -1,6 +1,9 @@
1
1
  module Optimacms
2
2
  module Admin
3
3
  class AdminBaseController < ApplicationController
4
+ before_action :authenticate_cms_admin_user!
5
+
6
+
4
7
  layout 'optimacms/admin/layouts/main'
5
8
 
6
9
  add_flash_types :success
@@ -19,6 +22,16 @@ module Optimacms
19
22
  end
20
23
 
21
24
 
25
+ def after_sign_in_path_for(resource)
26
+ if resource.is_a?(CmsAdminUser)
27
+ dashboard_path
28
+ else
29
+ root_path
30
+ end
31
+
32
+ end
33
+
34
+
22
35
  end
23
36
  end
24
37
  end
@@ -18,9 +18,13 @@ module Optimacms
18
18
 
19
19
  def index
20
20
  #
21
- @parent_id = @filter.v('parent_id')
21
+ @parent_id = @filter.v('parent_id').to_i
22
22
  @parent = Template.find(@parent_id) rescue nil
23
23
 
24
+ if @parent.nil? && @parent_id>0
25
+ redirect_to templates_path(:parent_id=>0) and return
26
+ end
27
+
24
28
  #
25
29
  @items = model.list(@filter, @pg)
26
30
 
@@ -16,6 +16,17 @@ module Optimacms
16
16
 
17
17
  #FileUtils.rm(f)
18
18
  end
19
+
20
+ def addadminuser
21
+ row = Optimacms::CmsAdminUser.new
22
+ row.email = 'admin@example.com'
23
+ row.password = 'admin'
24
+
25
+ row.save
26
+ end
19
27
  end
28
+
29
+
30
+
20
31
  end
21
32
 
@@ -1,7 +1,8 @@
1
1
  module Optimacms
2
2
  module ApplicationHelper
3
3
 
4
- include ActionView::Helpers::ApplicationHelper
4
+ #include ActionView::Helpers::ApplicationHelper
5
+ x=0
5
6
 
6
7
  def method_missing(method, *args, &block)
7
8
  main_app.send(method, *args, &block)
@@ -0,0 +1,10 @@
1
+ module Optimacms
2
+ class CmsAdminUser < ActiveRecord::Base
3
+ self.table_name = 'cms_users'
4
+
5
+ # Include default devise modules. Others available are:
6
+ # :confirmable, :lockable, :timeoutable and :omniauthable
7
+ #devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
8
+ devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ <h2>Resend confirmation instructions</h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
10
+
11
+ <div class="actions">
12
+ <%= f.submit "Resend confirmation instructions" %>
13
+ </div>
14
+ <% end %>
15
+
16
+ <%= render "cms_admin_users/shared/links" %>
@@ -0,0 +1,5 @@
1
+ <p>Welcome <%= @email %>!</p>
2
+
3
+ <p>You can confirm your account email through the link below:</p>
4
+
5
+ <p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
@@ -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: @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: @token) %></p>
@@ -0,0 +1,22 @@
1
+ <h2>Change your password</h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+ <%= f.hidden_field :reset_password_token %>
6
+
7
+ <div class="field">
8
+ <%= f.label :password, "New password" %><br />
9
+ <%= f.password_field :password, autofocus: true, autocomplete: "off" %>
10
+ </div>
11
+
12
+ <div class="field">
13
+ <%= f.label :password_confirmation, "Confirm new password" %><br />
14
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
15
+ </div>
16
+
17
+ <div class="actions">
18
+ <%= f.submit "Change my password" %>
19
+ </div>
20
+ <% end %>
21
+
22
+ <%= render "cms_admin_users/shared/links" %>
@@ -0,0 +1,16 @@
1
+ <h2>Forgot your password?</h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
10
+
11
+ <div class="actions">
12
+ <%= f.submit "Send me reset password instructions" %>
13
+ </div>
14
+ <% end %>
15
+
16
+ <%= render "cms_admin_users/shared/links" %>
@@ -0,0 +1,39 @@
1
+ <h2>Edit <%= resource_name.to_s.humanize %></h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
10
+
11
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
12
+ <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
13
+ <% end %>
14
+
15
+ <div class="field">
16
+ <%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
17
+ <%= f.password_field :password, autocomplete: "off" %>
18
+ </div>
19
+
20
+ <div class="field">
21
+ <%= f.label :password_confirmation %><br />
22
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
23
+ </div>
24
+
25
+ <div class="field">
26
+ <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
27
+ <%= f.password_field :current_password, autocomplete: "off" %>
28
+ </div>
29
+
30
+ <div class="actions">
31
+ <%= f.submit "Update" %>
32
+ </div>
33
+ <% end %>
34
+
35
+ <h3>Cancel my account</h3>
36
+
37
+ <p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
38
+
39
+ <%= link_to "Back", :back %>
@@ -0,0 +1,29 @@
1
+ <h2>Sign up</h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
10
+
11
+ <div class="field">
12
+ <%= f.label :password %>
13
+ <% if @validatable %>
14
+ <em>(<%= @minimum_password_length %> characters minimum)</em>
15
+ <% end %><br />
16
+ <%= f.password_field :password, autocomplete: "off" %>
17
+ </div>
18
+
19
+ <div class="field">
20
+ <%= f.label :password_confirmation %><br />
21
+ <%= f.password_field :password_confirmation, autocomplete: "off" %>
22
+ </div>
23
+
24
+ <div class="actions">
25
+ <%= f.submit "Sign up" %>
26
+ </div>
27
+ <% end %>
28
+
29
+ <%= render "cms_admin_users/shared/links" %>
@@ -0,0 +1,26 @@
1
+ <h2>Log in</h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
4
+ <div class="field">
5
+ <%= f.label :email %><br />
6
+ <%= f.email_field :email, autofocus: true %>
7
+ </div>
8
+
9
+ <div class="field">
10
+ <%= f.label :password %><br />
11
+ <%= f.password_field :password, autocomplete: "off" %>
12
+ </div>
13
+
14
+ <% if devise_mapping.rememberable? -%>
15
+ <div class="field">
16
+ <%= f.check_box :remember_me %>
17
+ <%= f.label :remember_me %>
18
+ </div>
19
+ <% end -%>
20
+
21
+ <div class="actions">
22
+ <%= f.submit "Log in" %>
23
+ </div>
24
+ <% end %>
25
+
26
+ <%= render "cms_admin_users/shared/links" %>
@@ -0,0 +1,25 @@
1
+ <%- if controller_name != 'sessions' %>
2
+ <%= link_to "Log in", new_session_path(resource_name) %><br />
3
+ <% end -%>
4
+
5
+ <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
6
+ <%= link_to "Sign up", new_registration_path(resource_name) %><br />
7
+ <% end -%>
8
+
9
+ <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
10
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
11
+ <% end -%>
12
+
13
+ <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
14
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
15
+ <% end -%>
16
+
17
+ <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
18
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
19
+ <% end -%>
20
+
21
+ <%- if devise_mapping.omniauthable? %>
22
+ <%- resource_class.omniauth_providers.each do |provider| %>
23
+ <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
24
+ <% end -%>
25
+ <% end -%>
@@ -0,0 +1,16 @@
1
+ <h2>Resend unlock instructions</h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <div class="field">
7
+ <%= f.label :email %><br />
8
+ <%= f.email_field :email, autofocus: true %>
9
+ </div>
10
+
11
+ <div class="actions">
12
+ <%= f.submit "Resend unlock instructions" %>
13
+ </div>
14
+ <% end %>
15
+
16
+ <%= render "cms_admin_users/shared/links" %>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Optimacms</title>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6
+ <%= stylesheet_link_tag "optimacms/application", media: "all" %>
7
+ <%= javascript_include_tag "optimacms/application" %>
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -9,17 +9,25 @@
9
9
  <a class="navbar-brand" href="#"><small><i class="fa fa-cube"></i> Admin</small></a>
10
10
  .navbar-buttons.pull-right(role="navigation")
11
11
  %ul.nav
12
+ -#%li
13
+ =link_to 'Login', new_user_session_path
12
14
  %li
13
15
  %a.dropdown-toggle(href="#" data-toggle="dropdown" aria-expanded="true")
14
16
  %span.user-info Admin
15
17
  %i.fa.fa-caret-down
16
18
  %ul.dropdown-menu-right.dropdown-menu
19
+ %li
20
+ %a{:href => '#'}
21
+ = fa_icon "user"
22
+ #{current_cms_admin_user.email}
17
23
  %li
18
24
  <a href="#"><i class="fa fa-cog"></i> Settings</a>
19
25
  %li
20
26
  <a href="profile.html"><i class="fa fa-user"></i> Profile</a>
21
27
  %li.divider
22
28
  %li
23
- <a href="#"><i class="fa fa-power-off"></i> Logout</a>
29
+ =link_to destroy_cms_admin_user_session_path, :method => :delete do
30
+ = fa_icon "fa-power-off"
31
+ Logout
24
32
 
25
33
 
@@ -0,0 +1,60 @@
1
+ # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
+
3
+ en:
4
+ devise:
5
+ confirmations:
6
+ confirmed: "Your email address has been successfully confirmed."
7
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
9
+ failure:
10
+ already_authenticated: "You are already signed in."
11
+ inactive: "Your account is not activated yet."
12
+ invalid: "Invalid %{authentication_keys} or password."
13
+ locked: "Your account is locked."
14
+ last_attempt: "You have one more attempt before your account is locked."
15
+ not_found_in_database: "Invalid %{authentication_keys} or password."
16
+ timeout: "Your session expired. Please sign in again to continue."
17
+ unauthenticated: "You need to sign in or sign up before continuing."
18
+ unconfirmed: "You have to confirm your email address before continuing."
19
+ mailer:
20
+ confirmation_instructions:
21
+ subject: "Confirmation instructions"
22
+ reset_password_instructions:
23
+ subject: "Reset password instructions"
24
+ unlock_instructions:
25
+ subject: "Unlock instructions"
26
+ omniauth_callbacks:
27
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
28
+ success: "Successfully authenticated from %{kind} account."
29
+ passwords:
30
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
31
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
32
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
33
+ updated: "Your password has been changed successfully. You are now signed in."
34
+ updated_not_active: "Your password has been changed successfully."
35
+ registrations:
36
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
37
+ signed_up: "Welcome! You have signed up successfully."
38
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
39
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
40
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
41
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
42
+ updated: "Your account has been updated successfully."
43
+ sessions:
44
+ signed_in: "Signed in successfully."
45
+ signed_out: "Signed out successfully."
46
+ already_signed_out: "Signed out successfully."
47
+ unlocks:
48
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
49
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
50
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
51
+ errors:
52
+ messages:
53
+ already_confirmed: "was already confirmed, please try signing in"
54
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
55
+ expired: "has expired, please request a new one"
56
+ not_found: "not found"
57
+ not_locked: "was not locked"
58
+ not_saved:
59
+ one: "1 error prohibited this %{resource} from being saved:"
60
+ other: "%{count} errors prohibited this %{resource} from being saved:"
data/config/routes.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  Optimacms::Engine.routes.draw do
2
- resources :articles
3
2
 
4
3
  # admin
5
4
  scope '/cmsadmin', module: "admin" do
5
+ #devise_for :users, { class_name: "Optimacms::User", module: :devise }
6
+
6
7
  get '/' => 'dashboard#index', as: :dashboard
7
8
 
8
9
  resources :pages do
@@ -0,0 +1,42 @@
1
+ class DeviseCreateOptimacmsCmsUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table(:optimacms_cms_users) do |t|
4
+ ## Database authenticatable
5
+ t.string :email, null: false, default: ""
6
+ t.string :encrypted_password, null: false, default: ""
7
+
8
+ ## Recoverable
9
+ t.string :reset_password_token
10
+ t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Trackable
16
+ t.integer :sign_in_count, default: 0, null: false
17
+ t.datetime :current_sign_in_at
18
+ t.datetime :last_sign_in_at
19
+ t.string :current_sign_in_ip
20
+ t.string :last_sign_in_ip
21
+
22
+ ## Confirmable
23
+ # t.string :confirmation_token
24
+ # t.datetime :confirmed_at
25
+ # t.datetime :confirmation_sent_at
26
+ # t.string :unconfirmed_email # Only if using reconfirmable
27
+
28
+ ## Lockable
29
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
30
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
31
+ # t.datetime :locked_at
32
+
33
+
34
+ t.timestamps
35
+ end
36
+
37
+ add_index :optimacms_cms_users, :email, unique: true
38
+ add_index :optimacms_cms_users, :reset_password_token, unique: true
39
+ # add_index :optimacms_cms_users, :confirmation_token, unique: true
40
+ # add_index :optimacms_cms_users, :unlock_token, unique: true
41
+ end
42
+ end
@@ -0,0 +1,88 @@
1
+
2
+ require 'devise'
3
+
4
+ module Optimacms
5
+ module Devise
6
+
7
+ def self.config
8
+ {
9
+ class_name: "Optimacms::CmsAdminUser",
10
+ path: '/cmsadmin',
11
+ #path: ActiveAdmin.application.default_namespace || "/",
12
+ controllers: Optimacms::Devise.controllers,
13
+ path_names: { sign_in: 'login', sign_out: "logout" },
14
+ #sign_out_via: [*::Devise.sign_out_via, ActiveAdmin.application.logout_link_method].uniq
15
+ }
16
+ end
17
+
18
+ def self.controllers
19
+ {
20
+ sessions: "optimacms/devise/sessions",
21
+ passwords: "optimacms/devise/passwords",
22
+ unlocks: "optimacms/devise/unlocks",
23
+ registrations: "optimacms/devise/registrations",
24
+ confirmations: "optimacms/devise/confirmations"
25
+ }
26
+ end
27
+
28
+
29
+ # got from activeadmin
30
+
31
+ module Controller
32
+ extend ::ActiveSupport::Concern
33
+
34
+ included do
35
+ layout 'optimacms/application_logged_out'
36
+ #helper ::Optimacms::ViewHelpers
37
+ end
38
+
39
+ # Redirect to the default namespace on logout
40
+ def root_path
41
+ return '/'
42
+ #namespace = Optimacms.application.default_namespace.presence
43
+ namespace = nil
44
+ root_path_method = [namespace, :root_path].compact.join('_')
45
+
46
+ path = if Helpers::Routes.respond_to? root_path_method
47
+ Helpers::Routes.send root_path_method
48
+ else
49
+ # Guess a root_path when url_helpers not helpful
50
+ "/#{namespace}"
51
+ end
52
+
53
+ # NOTE: `relative_url_root` is deprecated by rails.
54
+ # Remove prefix here if it is removed completely.
55
+ #prefix = Rails.configuration.action_controller[:relative_url_root] || ''
56
+ prefix = ''
57
+ prefix + path
58
+ end
59
+ end
60
+
61
+
62
+
63
+ class SessionsController < ::Devise::SessionsController
64
+ include ::Optimacms::Devise::Controller
65
+ end
66
+
67
+ class PasswordsController < ::Devise::PasswordsController
68
+ include ::Optimacms::Devise::Controller
69
+ end
70
+
71
+ class UnlocksController < ::Devise::UnlocksController
72
+ include ::Optimacms::Devise::Controller
73
+ end
74
+
75
+ class RegistrationsController < ::Devise::RegistrationsController
76
+ include ::Optimacms::Devise::Controller
77
+ end
78
+
79
+ class ConfirmationsController < ::Devise::ConfirmationsController
80
+ include ::Optimacms::Devise::Controller
81
+ end
82
+
83
+ def self.controllers_for_filters
84
+ [SessionsController, PasswordsController, UnlocksController, RegistrationsController, ConfirmationsController
85
+ ]
86
+ end
87
+ end
88
+ end
@@ -1,3 +1,4 @@
1
+
1
2
  module Optimacms
2
3
  class Engine < ::Rails::Engine
3
4
  isolate_namespace Optimacms
@@ -1,3 +1,3 @@
1
1
  module Optimacms
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.14"
3
3
  end
data/lib/optimacms.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'devise'
1
2
  require "optimacms/engine"
2
3
 
3
4
  module Optimacms
@@ -0,0 +1,6 @@
1
+ class User < ActiveRecord::Base
2
+ # Include default devise modules. Others available are:
3
+ # :confirmable, :lockable, :timeoutable and :omniauthable
4
+ devise :database_authenticatable, :registerable,
5
+ :recoverable, :rememberable, :trackable, :validatable
6
+ end
@@ -2,6 +2,10 @@
2
2
  %ul
3
3
  %li= link_to '/cmsadmin', '/cmsadmin'
4
4
 
5
+ %h2 Users
6
+ %ul
7
+ %li= link_to 'Login', new_user_session_path
8
+
5
9
  %h2 Pages
6
10
 
7
11
  %ul