Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Descrizione

Questo metodo può essere utilizzato per resettare la password di un cliente all'interno del sistema.

Utilizzo

I parametri richiesti da questo metodo sono:

  • customerId: Id del cliente di cui si vuole resettare la password.
  • secureQuestionId: Id della domanda di sicurezza scelta dall'utente. Per ottenere maggiori informazioni e la lista delle domande consultare bGetSecureQuestions.
  • secureAnswerHash_MD5: Hash in formato SHA1 MD5 della risposta alla domanda di sicurezza dell'attuale password dell'utente.
  • secureAnswerHash_SHA1Hash in formato MD5 della SHA1 della risposta alla domanda di sicurezza dell'utente.
  • customerNewPasswordHash: Hash in formato SHA1 della nuova password dell'utente, false se si vuole che la password venga generata in automatico.

 In caso di successo, se si è scelto di generare in automatico la password, ritorna una stringa che rappresenta la nuova password dell'utente, altrimenti ritorna una stringa vuota.

Gestione errori

In caso di errore il metodo genererà un'eccezione che riporterà uno dei seguenti codici di errore:

  • ERROR_INVALID_PARAMS: Uno dei parametri inviati non è valido.
  • ERROR_INVALID_TOKEN: Non è stato effettuato nessun login in precedenza o la sessione è scaduta per inutilizzo.
  • ERROR_INVALID_IP: L'indirizzo ip del server che sta effettuando la chiamata non valido perchè non inserito nella whitelist associata alle credenziali.
  • ERROR_SERVER_UNAVAILABLE: Il server non è disponibile o si è verificato un errore di comunicazione generico.

 

Code Block
languagephp
titlePHP
linenumberstrue
require "vendor/autoload.php"
 
try {
    $ezPrintSDK = new ezPrintSDKWrapper('http://demo.ezprint.it');
	$apiToken = $ezPrintSDK->cLoginAPI('1WHm0icsupAEm9fil9en','yCHZ0nKiyn1MU0DhpgmG');
 
	$customers = $ezPrintSDK->backOffice->bGetCustomers(false);
	$newPassword = $ezPrintSDK->backOffice->bResetCustomerPassword($customers[0]['customerId'], 1, md5("risposta"), sha1("risposta"), false);
} catch (Exception $e) {
    echo 'Error Code: ',  $e->getMessage();
}

Code Block
languagejs
titleNode.js
linenumberstrue
try {
	var ezPrintSDK = require('ezprint-sdk-wrapper');
	var sha1 = require('sha1');
	var md5 = require('md5');
	
	ezPrintSDK.initializeWrapper('http://demo.ezprint.it');
    var apiToken = ezPrintSDK.cLoginAPI('1WHm0icsupAEm9fil9en','yCHZ0nKiyn1MU0DhpgmG');
	
	var customers = ezPrintSDK.backOffice.bGetCustomers(false);
	var newPassword = ezPrintSDK.backOffice.bResetCustomerPassword(customer[0].customerId, 1, md5("risposta"), sha1("risposta"), false);
} catch (ex) {
	console.log(ex);
}
Code Block
languagec#
title.NET (C#)
linenumberstrue
try {
	ezPrintSDKWrapper.Client ezPrintSDK = new ezPrintSDKWrapper.Client("http://demo.ezprint.it");
	ezPrintSDK.cLoginAPI("1WHm0icsupAEm9fil9en","yCHZ0nKiyn1MU0DhpgmG");
	
	List<ezPrintSDKWrapper.Structures.customerItem> customers = ezPrintSDK.BackOffice.bGetCustomers(false);
 
	HashAlgorithm algorithmSHA1 = SHA1.Create();
    MD5 algorithmalgorithmMD5 = MD5.Create();
	    StringBuilder sb1 = new StringBuilder();
    StringBuilder sb2 = new StringBuilder();
 
	foreach (byte b in algorithmalgorithmMD5.ComputeHash(Encoding.UTF8.GetBytes("risposta")))
		sb1.Append(b.ToString("x2"));
 
	foreach (byte b in algorithmSHA1.ComputeHash(Encoding.UTF8.GetBytes("risposta")))
        sb2.Append(b.ToString("x2"));

	string newPassword = ezPrintSDK.BackOffice.bResetCustomerPassword(customers[0].customerId, 1, sb1.ToString(), sb2.ToString(), false);
} catch (ezPrintException ex) {
	string ErrorMessage = ex.Message;
}