Typecho实现注册时设置密码

前言

图片[1]-Typecho实现注册时设置密码-宅学院

打开 register.php

网站根目录/admin/register.php

在Email<p></p>标签下添加以下代码

<p>
<input type="password" class="text-l w-100" id="password" name="password" autocomplete="current-password" placeholder="输入密码" required="">
</p>
<p>
<input type="password" class="text-l w-100" id="confirm" name="confirm" autocomplete="current-password" placeholder="再次输入密码" required="">
</p>

打开 Register.php

网站根目录/var/Widget/Register.php

找到

        $hasher = new PasswordHash(8, true);
        $generatedPassword = Typecho_Common::randString(7);

        $dataStruct = array(
            'name'      =>  $this->request->name,
            'mail'      =>  $this->request->mail,
            'screenName'=>  $this->request->name,
            'password'  =>  $hasher->HashPassword($generatedPassword),
            'created'   =>  $this->options->time,
            'group'     =>  'subscriber'
        );

将 $generatedPassword = Typecho_Common::randString(7); 替换为以下代码

        /** 如果请求中含有password则设置为密码,否则随机密码 */
        if (array_key_exists('password', $_REQUEST)) {
        $generatedPassword = $this->request->password;
        }
        else
        {
        $generatedPassword = Typecho_Common::randString(7);
        }

© 版权声明
THE END
喜欢就支持一下吧
点赞1 分享
评论 抢沙发