Module: Sorcery::Model::Submodules::MagicLogin::InstanceMethods

Defined in:
lib/sorcery/model/submodules/magic_login.rb

Instance Method Summary collapse

Instance Method Details

#clear_magic_login_token!Object

Clears the token.



113
114
115
116
117
118
119
# File 'lib/sorcery/model/submodules/magic_login.rb', line 113

def 
  config = sorcery_config
  sorcery_adapter.update_attributes(
    config. => nil,
    config. => nil
  )
end

#deliver_magic_login_instructions!Object

generates a magic login code with expiration and sends an email to the user.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/sorcery/model/submodules/magic_login.rb', line 94

def 
  mail = false
  config = sorcery_config
  # hammering protection
  return false if !config..nil? &&
                  send(config.) &&
                  send(config.) > config..seconds.ago

  self.class.sorcery_adapter.transaction do
    
    unless config.
      
      mail = true
    end
  end
  mail
end

#generate_magic_login_token!Object

generates a reset code with expiration



82
83
84
85
86
87
88
89
90
91
# File 'lib/sorcery/model/submodules/magic_login.rb', line 82

def 
  config = sorcery_config
  attributes = {
    config. => TemporaryToken.generate_random_token,
    config. => Time.now.in_time_zone
  }
  attributes[config.] = Time.now.in_time_zone + config. if config.

  sorcery_adapter.update_attributes(attributes)
end