Module: Sinatra::SimpleAuthentication::Controllers::Defaults

Defined in:
lib/sinatra/simple_authentication/controllers/defaults.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.invalid_email_messageObject

Returns the value of attribute invalid_email_message.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def invalid_email_message
  @invalid_email_message
end

.login_successful_messageObject

Returns the value of attribute login_successful_message.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def 
  @login_successful_message
end

.login_wrong_email_messageObject

Returns the value of attribute login_wrong_email_message.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def 
  @login_wrong_email_message
end

.login_wrong_password_messageObject

Returns the value of attribute login_wrong_password_message.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def 
  @login_wrong_password_message
end

.long_password_messageObject

Returns the value of attribute long_password_message.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def long_password_message
  @long_password_message
end

.max_password_lengthObject

Returns the value of attribute max_password_length.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def max_password_length
  @max_password_length
end

.min_password_lengthObject

Returns the value of attribute min_password_length.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def min_password_length
  @min_password_length
end

.missing_email_messageObject

Returns the value of attribute missing_email_message.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def missing_email_message
  @missing_email_message
end

.missing_password_confirmation_messageObject

Returns the value of attribute missing_password_confirmation_message.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def missing_password_confirmation_message
  @missing_password_confirmation_message
end

.missing_password_messageObject

Returns the value of attribute missing_password_message.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def missing_password_message
  @missing_password_message
end

.password_confirmation_dont_match_password_messageObject

Returns the value of attribute password_confirmation_dont_match_password_message.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def password_confirmation_dont_match_password_message
  @password_confirmation_dont_match_password_message
end

.short_password_messageObject

Returns the value of attribute short_password_message.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def short_password_message
  @short_password_message
end

.taken_email_messageObject

Returns the value of attribute taken_email_message.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def taken_email_message
  @taken_email_message
end

.use_password_confirmationObject

Returns the value of attribute use_password_confirmation.



8
9
10
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 8

def use_password_confirmation
  @use_password_confirmation
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



24
25
26
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 24

def self.configure(&block)
  yield self
end

.setDefaults(app) ⇒ Object



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
# File 'lib/sinatra/simple_authentication/controllers/defaults.rb', line 28

def self.setDefaults(app)
  app.set :sinatra_authentication_view_path, File.expand_path(File.join("../..", "views"), __FILE__)
  app.enable :sessions

  #Set costum variables
  app.set :use_password_confirmation, use_password_confirmation.nil? ? false : use_password_confirmation
  app.set :min_password_length, min_password_length.nil? ? 4 : min_password_length
  app.set :max_password_length, max_password_length.nil? ? 16 : max_password_length

  app.set :login_wrong_email_message, .nil? ? "Wrong email address." : 
  app.set :login_wrong_password_message, .nil? ? "Wrong password." : 
  app.set :login_successful_message, .nil? ? "Login successful." : 

  #Validations errors messages
  taken_email = taken_email_message.nil? ? "Email has already been taken." : taken_email_message
  missing_email = missing_email_message.nil? ? "Email can't be blank." : missing_email_message
  invalid_email = invalid_email_message.nil? ? "Invalid email format." : invalid_email_message
  missing_password = missing_password_message.nil? ? "Password can't be blank." : missing_password_message
  short_password = short_password_message.nil? ? "Password is too short, must be between #{app.settings.min_password_length} and #{app.settings.max_password_length} characters long." : short_password_message
  long_password = long_password_message.nil? ? "Password is too long, must be between #{app.settings.min_password_length} and #{app.settings.max_password_length} characters long." : long_password_message
  missing_password_confirmation = missing_password_confirmation_message.nil? ? "Password confirmation can't be blank." : missing_password_confirmation_message
  password_confirmation_dont_match_password = password_confirmation_dont_match_password_message.nil? ? "Password confirmation doesn't match password." : password_confirmation_dont_match_password_message

  app.set :error_messages, { :missing_email => missing_email,
    :taken_email => taken_email,
    :invalid_email => invalid_email,
    :missing_password => missing_password,
    :short_password => short_password,
    :long_password => long_password,
    :missing_password_confirmation => missing_password_confirmation,
    :password_confirmation_dont_match_password => password_confirmation_dont_match_password
  }

  app
end