user2073 Từ không xác định Thành viên kể từ thg 12 -0001 user2073 12 thg 3 2014 13:50 Hi,I would like to restrict the access to my site to a list of users which I have already in a database. Is it possible?Thanks
litecart Main Crew Từ Sweden Thành viên kể từ thg 2 2013 litecart 12 thg 3 2014 23:04 if (empty(customer::$data['id'])) die('Logged in users only!');
pulsehost LiteCart Fan Từ United Kingdom Thành viên kể từ thg 4 2023 pulsehost 18 thg 3 2024 23:14 i did a similar thing for a liteCart project. I didnt want non members to access the cart unless they were logged in. I put this code in /public_html/pages/checkout.inc.php but it could easily be used to protect the entire site from non members.<?phpif (empty(customer::$data['id'])) { header("Location: login?redirect_url=checkout");} else { header('X-Robots-Tag: noindex'); document::$layout = 'checkout'; if (settings::get('catalog_only_mode')) return; document::$snippets['title'][] = language::translate('checkout:head_title', 'Checkout'); breadcrumbs::add(language::translate('title_checkout', 'Checkout')); functions::draw_lightbox(); $_page = new ent_view(); echo $_page->stitch('pages/checkout');}
tim Founder Từ Sweden Thành viên kể từ thg 5 2013 tim 19 thg 3 2024 01:40 You don't need the else condition.if (empty(customer::$data['id'])) { header('Location: document::ilink('login', ['redirect_url' => $_SERVER['REQUEST_URI']])); exit;}Same ascustomer::require_login();
pulsehost LiteCart Fan Từ United Kingdom Thành viên kể từ thg 4 2023 pulsehost 19 thg 3 2024 12:26 Agreed that's the better solution: customer::require_login();However I don't get why there is no setting in admin to enforce login or not. There are many use cases to justify it.
tim Founder Từ Sweden Thành viên kể từ thg 5 2013 tim 19 thg 3 2024 22:42 I don't get why there is no setting in admin to enforce loginThere are many other things in queue, it just hasn't happened yet.
pulsehost LiteCart Fan Từ United Kingdom Thành viên kể từ thg 4 2023 pulsehost 20 thg 3 2024 00:26 Was't that functionality in an earlier version of LiteCart? I seem to remember something along those lines. I could be thinking of another project though.