Module: Authmotion::EmailLogin
- Defined in:
- lib/project/authmotion.rb
Instance Method Summary collapse
- #after_conection ⇒ Object
- #data_create_user ⇒ Object
-
#data_login_user ⇒ Object
This method is a hash, how we send the data ‘x’, password: ”.
- #errors ⇒ Object
- #errors_model(response) ⇒ Object
-
#failed_conection ⇒ Object
failed conection, should be a lambda.
- #has_enough_data_login? ⇒ Boolean
- #has_enough_data_register? ⇒ Boolean
-
#login_action ⇒ Object
method that should be call it for log in a user.
- #login_field ⇒ Object
- #other_error ⇒ Object
- #password_confirmation_field ⇒ Object
- #password_field ⇒ Object
- #password_field_simple? ⇒ Boolean
- #password_register_valid? ⇒ Boolean
-
#register_action ⇒ Object
method that should be call it for register a user.
- #success_conection_login ⇒ Object
- #success_conection_register ⇒ Object
-
#url_log_in ⇒ Object
Methods for conections.
- #url_register ⇒ Object
-
#user_field ⇒ Object
This methods should be implemented like a getters.
- #user_valid? ⇒ Boolean
- #waiting_view ⇒ Object
Instance Method Details
#after_conection ⇒ Object
63 |
# File 'lib/project/authmotion.rb', line 63 def after_conection ; end |
#data_create_user ⇒ Object
100 101 102 |
# File 'lib/project/authmotion.rb', line 100 def data_create_user raise "data_create_user MUST BE IMPLEMENTED" end |
#data_login_user ⇒ Object
This method is a hash, how we send the data
{login: 'x', password: ''}
96 97 98 |
# File 'lib/project/authmotion.rb', line 96 def data_login_user raise "data_login_user MUST BE IMPLEMENTED" end |
#errors ⇒ Object
104 105 106 |
# File 'lib/project/authmotion.rb', line 104 def errors raise "errors should be implemented" end |
#errors_model(response) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/project/authmotion.rb', line 42 def errors_model(response) = parse(response) ="" ["errors"].each do |field,| = " #{}\n #{field}: #{.join("\n")}" end () end |
#failed_conection ⇒ Object
failed conection, should be a lambda
128 129 130 131 132 133 134 135 136 137 |
# File 'lib/project/authmotion.rb', line 128 def failed_conection lambda do |response| if response.status_code.to_s =~ /40\d/ = "#{@action} failed" else = response. end () end end |
#has_enough_data_login? ⇒ Boolean
27 28 29 30 31 32 |
# File 'lib/project/authmotion.rb', line 27 def has_enough_data_login? if user_field.nil? or password_field.nil? raise "You need define email and password field" end user_valid? and password_field_simple? end |
#has_enough_data_register? ⇒ Boolean
34 35 36 37 38 39 |
# File 'lib/project/authmotion.rb', line 34 def has_enough_data_register? if user_field.nil? or password_field.nil? or password_confirmation_field.nil? raise "You need define email, password and password confirmation field" end user_valid? and password_register_valid? end |
#login_action ⇒ Object
method that should be call it for log in a user
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/project/authmotion.rb', line 16 def login_action @action = "login" waiting_view if has_enough_data_login? response = conection(url_log_in,data_login_user) else ("All fields are required") hide_waiting_view end end |
#login_field ⇒ Object
80 81 82 |
# File 'lib/project/authmotion.rb', line 80 def login_field raise "should be implemented" end |
#other_error ⇒ Object
65 66 67 |
# File 'lib/project/authmotion.rb', line 65 def other_error ("Unknow error") end |
#password_confirmation_field ⇒ Object
88 89 90 |
# File 'lib/project/authmotion.rb', line 88 def password_confirmation_field raise "should be implemented" end |
#password_field ⇒ Object
84 85 86 |
# File 'lib/project/authmotion.rb', line 84 def password_field raise "should be implemented" end |
#password_field_simple? ⇒ Boolean
55 56 57 |
# File 'lib/project/authmotion.rb', line 55 def password_field_simple? password_field.text != "" end |
#password_register_valid? ⇒ Boolean
59 60 61 |
# File 'lib/project/authmotion.rb', line 59 def password_register_valid? password_field.text != "" and password_confirmation_field.text == password_field.text end |
#register_action ⇒ Object
method that should be call it for register a user
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/project/authmotion.rb', line 4 def register_action @action = "Register" waiting_view if has_enough_data_register? response = conection(url_register,data_register_user) else ("All fields are required") hide_waiting_view end end |
#success_conection_login ⇒ Object
143 144 145 |
# File 'lib/project/authmotion.rb', line 143 def success_conection_login lambda{|response| ('Good, user login. May be you need change this :-) ')} end |
#success_conection_register ⇒ Object
139 140 141 |
# File 'lib/project/authmotion.rb', line 139 def success_conection_register lambda{|response| ('Good, user register. May be you need change this :-) ')} end |
#url_log_in ⇒ Object
Methods for conections
112 113 114 |
# File 'lib/project/authmotion.rb', line 112 def url_log_in raise 'should be implemented' end |
#url_register ⇒ Object
116 117 118 |
# File 'lib/project/authmotion.rb', line 116 def url_register raise 'should be implemented' end |
#user_field ⇒ Object
This methods should be implemented like a getters. example:
def user_field
@field #should be UITextField
end
76 77 78 |
# File 'lib/project/authmotion.rb', line 76 def user_field raise "should be implemented" end |
#user_valid? ⇒ Boolean
51 52 53 |
# File 'lib/project/authmotion.rb', line 51 def user_valid? user_field.text != "" end |
#waiting_view ⇒ Object
121 122 123 |
# File 'lib/project/authmotion.rb', line 121 def waiting_view raise "waiting_view should be implemented" end |