zoukankan      html  css  js  c++  java
  • Abp zero 登录 添加腾讯云验证码

    腾讯云验证码是为网页、App、小程序开发者提供的安全验证服务,基于腾讯多年的大数据积累和人工智能决策引擎,构建智能分级验证模型,最大程度保护业务安全的同时,提供更精细化的用户体验。

    • 腾讯云-->验证码控制台

    验证码控制台注册 AppID 和 AppSecret,注册后在控制台基础配置中查看相关的信息,如下图:

    • ABP Login 代码修改

    项目 /Views/Account/_Layout.cshtml  ,在 Head 标签的最后加入以下代码,引入验证 JS 文件。

    <script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>

    项目/Views/Account/Login.cshtml 

     <form class="m-login__form m-form login-form" asp-action="Login" method="post" >
            <input type="hidden" name="returnUrl" value="@ViewBag.ReturnUrl" />
            <input type="hidden" name="returnUrlHash" />
            <input type="hidden" name="ss" value="@ViewBag.SingleSignIn" />
            <div class="form-group m-form__group">
                <input class="form-control m-input" type="text" placeholder="@L("UserNameOrEmail")" name="usernameOrEmailAddress" autocomplete="off" value="@(Model.UserNameOrEmailAddress ?? "")" required>
            </div>
            <div class="form-group m-form__group">
                <input class="form-control m-input m-login__form-input--last" type="password" placeholder="@L("Password")" name="password" autocomplete="off">
            </div>
            <div class="row m-login__form-sub">
                <div class="col m--align-left">
                    <label class="m-checkbox m-checkbox--primary">
                        <input type="checkbox" name="rememberMe" value="true">
                        @L("RememberMe")
                        <span></span>
                    </label>
                </div>
                <div class="col m--align-right">
                    <a href="@Url.Action("ForgotPassword", "Account")" id="forget-password" class="m-link forget-password">@L("ForgotPassword")</a>
                </div>
            </div>
            <div class="m-login__form-action">
                <button type="button" class="btn btn-primary m-btn m-btn--pill m-btn--custom m-btn--air" id="TencentCaptcha"
                        data-appid="AppID"
                        data-cbfn="callback">
                    @L("LogIn")
                    </button>
                </div>
            </form>

    页面中添加JavaScripts回调函数代码

        <script type="text/javascript">
            window.callback = function (res) {
                if (res.ret === 0) {
                    $("form").submit();
                }
                else {
                    abp.notify.warn("未验证,无法登录!");
                }
            }
        </script>

     

  • 相关阅读:
    [SCM]软件配置管理
    Jenkins入门总结
    Linux sh/bash[精华]
    [BRE]软件构建发布自动化
    python总结
    代码质量第 3 层 可读的代码
    记一次 WinDbg 分析 .NET 某工厂MES系统 内存泄漏分析
    记一次 .NET 某消防物联网 后台服务 内存泄漏分析
    Covariant(协变)与 Contravariant(逆变)
    三藩市湾区一周游
  • 原文地址:https://www.cnblogs.com/w2011/p/11942803.html
Copyright © 2011-2022 走看看