Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Apr 2013
    Posts
    8
    Plugin Contributions
    0

    Default Almost have my two-factor authentication working...

    Hi all,

    I taught myself PHP and MySQL primarily to hack some two-factor authentication via Authy www.authy.com into Zen Cart. I am getting close. I am nearly there, a couple observers and registration away. I have my API's working (through another observer), I am hoping that someone else can look over my registration code and see what I am missing? It isn't executing all the way through. I don't think it is the API's as they work for requiring Authy on login (another page I created, editing a new template for the default login). I'm hoping there is a simple error here.

    PHP Code:
    if (!defined('IS_ADMIN_FLAG')) {
      die(
    'Illegal Access');
    }

    require(
    DIR_WS_MODULES zen_get_module_directory('require_languages.php'));

    $breadcrumb->add(NAVBAR_TITLE);

    if (
    $_SESSION['customer_authy_token']) {
        
    zen_redirect(zen_href_link(FILENAME_ACCOUNT''$request_type));
    }

    require(
    DIR_WS_MODULES zen_get_module_directory('require_languages.php'));

    $api = new Authy_Api();
    $error false;

    if (isset(
    $_POST['action']) && ($_POST['action'] == 'process')) {
      
    $process true;
      
    $authy_email zen_db_prepare_input($_POST['authy-email']);
      
    $authy_country zen_db_prepare_input($_POST['authy-countries']);
      
    $authy_cellphone zen_db_prepare_input($_POST['authy-cellphone']);

      
    $check_customer_query "SELECT customers_id, customers_firstname, customers_lastname, customers_password,
                              customers_email_address, customers_default_address_id,
                              customers_authorization, customers_referral, customers_authy_id
                              FROM " 
    TABLE_CUSTOMERS "
                              WHERE customers_email_address = :emailAddress"
    ;

      
    $check_customer_query  =$db->bindVars($check_customer_query':emailAddress'$authy_email'string');
      
    $check_customer $db->Execute($check_customer_query);
      
      if (!
    $check_customer->RecordCount()) {
        
    $error true;
        
    $messageStack->add('two-factor'TEXT_AUTHY_EMAIL_ERROR);
      } elseif (
    $check_customer->fields['customers_authy_id'] != NULL) {
        
    // Check if customer is already registered with Authy and my site
        
    $error true;
        
    $messageStack->add('two-factor'TEXT_AUTHY_EMAIL_ERROR);
        } else {
          
    // Run Authy registration
          
    $user $api->registerUser($authy_email$authy_cellphone$authy_country);
          if (!
    $user->ok()) {
            
    $error true;
            
    $messageStack->add('two-factor'TEXT_AUTHY_REGISTER_ERROR);
            } else {
              if (
    $user->ok()) {
                
    $sql "update " TABLE_CUSTOMERS "
                         set customers_authy_id = '" 
    . (int)$user->id() . "'
                       where customers_id = '" 
    . (int)$_SESSION['customer_id'] . "'";
                       
                
    $db->Execute($sql);
                   
    $_SESSION['customer_authy_token'] = $check_customer->fields['customers_authy_id'];
                
    zen_redirect(zen_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS'''SSL'));
              }  
            }
        }

    Thanks.

  2. #2
    Join Date
    Apr 2013
    Posts
    8
    Plugin Contributions
    0

    Default Re: Almost have my two-factor authentication working...

    Should I post this in a different section?

  3. #3
    Join Date
    Feb 2005
    Location
    Lansing, Michigan USA
    Posts
    20,021
    Plugin Contributions
    3

    Default Re: Almost have my two-factor authentication working...

    Probably the right forum, but there are relatively few people here who are coder enough to dissect your code, so you may have to wait for a while. Is this for the admin login, or customer login ?

  4. #4
    Join Date
    Apr 2013
    Posts
    8
    Plugin Contributions
    0

    Default Re: Almost have my two-factor authentication working...

    Quote Originally Posted by stevesh View Post
    Probably the right forum, but there are relatively few people here who are coder enough to dissect your code, so you may have to wait for a while. Is this for the admin login, or customer login ?
    Thanks, I am still pretty new so any advice is good. It's for the customer login. I created a special form to register with my two-factor authentication provider and it isn't going through, I know the form itself is correct so I was hoping I was missing a simple "else" issue or something that someone could see quickly.

 

 

Similar Threads

  1. v153 2 factor authentication: Yubikey, Fido key, etc
    By RixStix in forum General Questions
    Replies: 3
    Last Post: 10 May 2019, 12:10 PM
  2. Two factor authentication for customers?
    By veryveryinteresting in forum All Other Contributions/Addons
    Replies: 7
    Last Post: 23 Aug 2013, 04:04 PM
  3. Negative price factor not working
    By ctlajoie in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 19 May 2009, 05:31 PM
  4. Replies: 2
    Last Post: 24 Mar 2009, 10:15 PM
  5. Can I have multiple options boxes using the multiplication factor?
    By infocom in forum Setting Up Categories, Products, Attributes
    Replies: 5
    Last Post: 8 Oct 2007, 10:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg