Class: Crm::Contact
- Inherits:
-
Crm::Core::BasicResource
- Object
- Crm::Core::BasicResource
- Crm::Contact
- Extended by:
- Crm::Core::Mixins::Findable::ClassMethods, Crm::Core::Mixins::Modifiable::ClassMethods, Crm::Core::Mixins::Searchable::ClassMethods
- Includes:
- Crm::Core::Mixins::ChangeLoggable, Crm::Core::Mixins::Findable, Crm::Core::Mixins::Inspectable, Crm::Core::Mixins::MergeAndDeletable, Crm::Core::Mixins::Modifiable, Crm::Core::Mixins::Searchable
- Defined in:
- lib/crm/contact.rb
Overview
A JustRelate WebCRM contact represents contact information about a person. It can be associated with an account.
Authentication and password management collapse
-
.authenticate(login, password) ⇒ Contact?
Authenticates a contact using their
login
andpassword
. -
.authenticate!(login, password) ⇒ Contact
Authenticates a contact using their
login
andpassword
. -
.set_password_by_token(new_password, token) ⇒ Contact
Sets a contact’s new password by means of the token.
-
#clear_password ⇒ self
Clears the contact’s password.
-
#generate_password_token ⇒ String
Generates a password token.
-
#send_password_token_email ⇒ void
Sends a password token by email to this contact.
-
#set_password(new_password) ⇒ self
Sets the new password.
Methods included from Crm::Core::Mixins::Findable::ClassMethods
Methods included from Crm::Core::Mixins::Modifiable::ClassMethods
Methods included from Crm::Core::Mixins::Searchable::ClassMethods
all, first, query, search_configurator, where, where_not
Methods included from Crm::Core::Mixins::Inspectable
Methods included from Crm::Core::Mixins::MergeAndDeletable
Methods included from Crm::Core::Mixins::ChangeLoggable
Methods included from Crm::Core::Mixins::Modifiable
Methods inherited from Crm::Core::BasicResource
base_type, #eql?, #id, path, #path, #reload, resource_name, #type
Methods included from Crm::Core::Mixins::AttributeProvider
#[], #attributes, #initialize, #method_missing, #methods, #raw, #respond_to_missing?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Crm::Core::Mixins::AttributeProvider
Class Method Details
.authenticate(login, password) ⇒ Contact?
Authenticates a contact using their login
and password
.
54 55 56 57 58 |
# File 'lib/crm/contact.rb', line 54 def self.authenticate(login, password) authenticate!(login, password) rescue Errors::AuthenticationFailed nil end |
.authenticate!(login, password) ⇒ Contact
Authenticates a contact using their login
and password
.
35 36 37 38 |
# File 'lib/crm/contact.rb', line 35 def self.authenticate!(login, password) new(Core::RestApi.instance.put("#{path}/authenticate", {'login' => login, 'password' => password})) end |
.set_password_by_token(new_password, token) ⇒ Contact
Sets a contact’s new password by means of the token. Generate a token by calling #send_password_token_email or #generate_password_token.
Use case: A contact clicks a link (that includes a token) in an email to get to a password change page.
91 92 93 94 95 96 |
# File 'lib/crm/contact.rb', line 91 def self.set_password_by_token(new_password, token) new(Core::RestApi.instance.put("#{path}/set_password_by_token", { 'password' => new_password, 'token' => token, })) end |
Instance Method Details
#clear_password ⇒ self
Clears the contact’s password.
101 102 103 |
# File 'lib/crm/contact.rb', line 101 def clear_password load_attributes(Core::RestApi.instance.put("#{path}/clear_password", {})) end |
#generate_password_token ⇒ String
Generates a password token.
Use case: A project sends an email to the contact. The email contains a link to the project web app. The link contains the param ?token=…. The web app retrieves and parses the token and passes it to set_password_by_token.
77 78 79 |
# File 'lib/crm/contact.rb', line 77 def generate_password_token Core::RestApi.instance.post("#{path}/generate_password_token", {})['token'] end |
#send_password_token_email ⇒ void
This method returns an undefined value.
Sends a password token by email to this contact.
Put a link to the project web app into the password_request_email_body
template. The link should contain the ?token=… parameter, e.g.:
https://example.com/user/set_password?token={{password_request_token}}
The web app can then pass the token to set_password_by_token.
115 116 117 |
# File 'lib/crm/contact.rb', line 115 def send_password_token_email Core::RestApi.instance.post("#{path}/send_password_token_email", {}) end |