Class: SecurityPageModelsMigration

Inherits:
Migration
  • Object
show all
Defined in:
lib/migrations/yodel/09_security_page_models.rb

Class Method Summary collapse

Class Method Details

.down(site) ⇒ Object



31
32
33
34
35
# File 'lib/migrations/yodel/09_security_page_models.rb', line 31

def self.down(site)
  site..destroy
  site.logout_pages.destroy
  site.password_reset_pages.destroy
end

.up(site) ⇒ Object



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
# File 'lib/migrations/yodel/09_security_page_models.rb', line 2

def self.up(site)
  site.pages.create_model :login_pages do ||
    add_field :username_field, :string, validations: {required: {}}, default: 'username'
    add_field :password_field, :string, validations: {required: {}}, default: 'password'
    add_one   :redirect_to, model: :page
    .record_class_name = 'LoginPage'
  end
  
  site.pages.create_model :logout_pages do |logout_pages|
    add_one :redirect_to, model: :page
    logout_pages.record_class_name = 'LogoutPage'
  end
  
  site.pages.create_model :password_reset_pages do |password_reset_pages|
    add_field :success, :html, default: 'Thank you, your password has been emailed to your email address.'
    add_field :email_field, :string, validations: {required: {}}, default: 'email'
    password_reset_pages.record_class_name = 'PasswordResetPage'
  end
  
  site.pages.create_model :facebook_login_pages do ||
    add_field :callback_uri, :string
    add_field :app_id, :string
    add_field :app_secret, :string
    add_one   :join_page, model: :page
    add_one   :after_login_page, model: :page
    .record_class_name = 'FacebookLoginPage'
  end
end