Mojolicious 中的单一密码授权

问题描述 投票:0回答:1

我想在Mojolicious中实现单密码授权而不是Basic-Auth。

我需要显示标准的基本身份验证字段,但只要求用户输入密码,而不必查看用户名字段。

plugin 'basic_auth', { realm => '', authenticator => sub {
    my ($password) = @_;

    return $password eq 'correct_password';
}};


my $authenticated = $c->basic_auth(realm => 'Restricted area', username => '', password => 'password');
    unless ($authenticated) {
        return { error => 'Authentication failed' };
    }

基本身份验证很容易实现,但我没有找到仅请求密码的能力。

也许有人知道如何仅请求访问密码?

我尝试了基本身份验证,但无法排除登录字段。

perl basic-authentication mojolicious
1个回答
0
投票

为什么不直接使用 HTML 的

<dialog>
元素呢?自 2022 年起广泛采用。只需问候语、密码字段以及登录和取消按钮即可轻松制作。通过内部表单,它可以以通常的方式将密码发送到您的 Mojo 或任何其他脚本。您可以根据需要设置对话框的样式。如果您想要一个最小的示例,我会发布一个。参考:MDN 文档

© www.soinside.com 2019 - 2024. All rights reserved.