【发布时间】:2014-09-04 08:28:34
【问题描述】:
我在 Magento 网站上工作,客户希望应该有一个自定义登录页面,其中只有 2 个字段用户名和密码。用户名和密码与客户的注册不同。这将是静态的,说用户名是 abc,密码是 xyz . 当任何人访问该站点时,他只需输入用户名和密码即可查看商店。
我该怎么做?
【问题讨论】:
标签: magento
我在 Magento 网站上工作,客户希望应该有一个自定义登录页面,其中只有 2 个字段用户名和密码。用户名和密码与客户的注册不同。这将是静态的,说用户名是 abc,密码是 xyz . 当任何人访问该站点时,他只需输入用户名和密码即可查看商店。
我该怎么做?
【问题讨论】:
标签: magento
basic access authentication 和 set .htpasswd您可以在 magento 的 index.php 中添加一些代码来验证 isset cookie 的值(更简单的方法)(带有原始 index.php 的备份):
<?php
if (!isset($_COOKIE['auth1'])){
if(!isset($_POST['prelogin']) and !isset($_POST['prepass'])){
//your form to post
?>
<h1>Authentication Required</h1>
<form method=post>
<input type=text id=prelogin name=prelogin value=login>
<input type=text id=password name=password value=password>
<input type=submit value=submit>
</form>
<?php
} else { //isset $_POST
//...
//your login+password check code
//...
setcookie("auth1", "your_md5(md5(pass))", time()+60*60*24*100, "/");
header( 'Location: /index.php', true, 303 );
}
} else { //isset $_COOKIE['auth1']
//...
//other $_COOKIE['auth1'] checks here
//....
//main magento code
}
?>
接下来使用
制作差异补丁 diff -u index.php.bak index.php > auth.patch
升级你的magento版本后,只需启动
patch index.php < auth.patch
【讨论】: