Module: Growatt::Authentication
- Included in:
- API
- Defined in:
- lib/growatt/authorization.rb
Overview
Handles authentication flow and stores session data in the global configuration.
This module provides methods for logging into the Growatt portal, hashing passwords, and validating credentials.
Instance Method Summary collapse
-
#login ⇒ Hash
Logs in to the Growatt portal using the stored credentials.
Instance Method Details
#login ⇒ Hash
Logs in to the Growatt portal using the stored credentials.
This method:
-
Validates that the username and password are set.
-
Hashes the password using MD5.
-
Sends a login request with the credentials.
-
Processes the server response.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/growatt/authorization.rb', line 28 def login validate_credentials _password = hash_password(self.password) # Hash password before sending _format = self.format self.format = 'x-www-form-urlencoded' response = post('newTwoLoginAPI.do', { 'userName' => self.username, 'password' => _password }) self.format = _format process_response(response.body['back']) end |