Beispiel #1
0
     $request = $connector->parseResponse($_REQUEST['data']);
     if (!$connector->responseIsOk($request) || empty($request['data']['user_login']) || empty($request['data']['password'])) {
         $connector->onError();
     }
     $_POST = $_REQUEST = array_merge($_REQUEST, $request['data']);
     list($status, $user_data, $user_login, $password, $salt) = fn_auth_routines($_REQUEST, $auth);
     $redirect_to_mv_url = fn_twg_check_for_vendor_url($status, $user_data);
     if ($redirect_to_mv_url) {
         $status = true;
     }
     $is_ok = !empty($user_data) && !empty($password) && fn_generate_salted_password($password, $salt) == $user_data['password'];
     if ($status === false || !$is_ok) {
         $connector->onError();
     }
     $response_data = array('redirect_to_mv_url' => $redirect_to_mv_url, 'company_id' => $user_data['company_id'], 'can_view_orders' => fn_check_user_access($user_data['user_id'], 'view_orders'));
     $connector->respond($response_data);
 } elseif ($action == 'auth.app') {
     $_POST['password'] = $_REQUEST['password'];
     list($status, $user_data, $user_login, $password, $salt) = fn_auth_routines($_REQUEST, $auth);
     $redirect_to_mv_url = fn_twg_check_for_vendor_url($status, $user_data);
     if ($redirect_to_mv_url) {
         $response->setData(array('status' => 'ok'));
         $response->setData(array('redirect_to_mv_url' => $redirect_to_mv_url));
         $response->returnResponse();
     }
     $is_ok = !empty($user_data) && !empty($password) && fn_generate_salted_password($password, $salt) == $user_data['password'];
     if ($status === false || !$is_ok) {
         fn_twg_throw_error_denied($response, 'error_incorrect_login');
     }
     if ($user_data['user_type'] == 'A' && $user_data['company_id']) {
         $store_access_id = TwigmoSettings::get('customer_connections.' . $user_data['company_id'] . '.access_id');
Beispiel #2
0
    }
    $request = $connector->parseResponse($_REQUEST['data']);
    if (empty($request['data']) or empty($request['data']['url'])) {
        $connector->onError();
    }
    // Request is ok - check url
    if ($action == 'check.admin') {
        if ($request['data']['url'] != $connector->getAdminUrl()) {
            $connector->onError('Wrong admin url');
        }
    } else {
        $stores = fn_twg_get_stores();
        $store = reset($stores);
        $my_url = $connector->getCustomerUrl($store);
        if ($request['data']['url'] != $my_url) {
            $connector->onError('Wrong customer url');
        }
    }
    $connector->respond(array('result' => 'ok'));
} elseif ($action == 'repo.updated') {
    $connector = new TwigmoConnector();
    $stores = fn_twg_get_stores();
    $store = reset($stores);
    $all_stores = TwigmoSettings::get('customer_connections');
    if (empty($store) || empty($all_stores) || !isset($all_stores[$store['company_id']])) {
        $connector->onError('store_not_found');
    }
    $all_stores[$store['company_id']]['repo_revision'] = TIME;
    TwigmoSettings::set(array('customer_connections' => $all_stores));
    $connector->respond(array('result' => 'ok'));
}