samedi 15 février 2020

Two Factor Authentication does not return error message after form submit

I set up a 2FA library on my Laravel 5.8 project. What I want to do is just display error message when user types two factor auth code in 2FA's blade template page. My codeblocks are as follow:

google2fa.php

<?php

return [

/*
 * Auth container binding
 */

'enabled' => true,

/*
 * Lifetime in minutes.
 * In case you need your users to be asked for a new one time passwords from time to time.
 */

'lifetime' => 0, // 0 = eternal

/*
 * Renew lifetime at every new request.
 */

'keep_alive' => true,

/*
 * Auth container binding
 */

'auth' => 'auth',

/*
 * 2FA verified session var
 */

'session_var' => 'google2fa',

/*
 * One Time Password request input name
 */
'otp_input' => 'one_time_password',

/*
 * One Time Password Window
 */
'window' => 1,

/*
 * Forbid user to reuse One Time Passwords.
 */
'forbid_old_passwords' => false,

/*
 * User's table column for google2fa secret
 */
'otp_secret_column' => 'google2fa_secret',

/*
 * One Time Password View
 */
'view' => 'production.account.google2fa',

/*
 * One Time Password error message
 */
'error_messages' => [
    'wrong_otp' => "The 'One Time Password' typed was wrong.",
],

/*
 * Throw exceptions or just fire events?
 */
'throw_exceptions' => true,

];

and my google2fa.blade.php file:

<!DOCTYPE html>
<html lang="en" class="website-html">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="csrf-token" content=""/>

    <title></title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="robots" content=""/>
    <meta property="og:url" content="" />
    <meta property="og:type" content="website" />
    <meta property="og:title" content="" />
    <meta property="og:description" content="" />
    <meta property="og:image" content="" />
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:site" content="@">
    <meta name="twitter:creator" content="@">
    <meta name="twitter:title" content="">
    <meta name="twitter:description" content="">
    <meta name="twitter:image" content="">

    <link rel="canonical" href="" />
</head>

<body>
    <div class="page-wrapper">
        <!-- Preloader -->
        <div class="preloader"></div>
        @include('production.common.alerts.flyin')

        <!-- Header Style One -->
        <header class="main-header header-style-one">
            <!-- Header Upper -->
            <div class="header-upper">
                <div class="inner-container">
                    <div class="auto-container clearfix">
                        <!--Info-->
                        <div class="logo-outer">
                            <div class="logo"><a href="/"><img src="/colin/images/pci_logo_120_2.png?v={!!env('APP_STATIC_VERSION')!!}" alt="" title=""></a></div>
                        </div>

                        <!--Nav Box-->
                        <div class="nav-outer clearfix">
                            <!--Mobile Navigation Toggler-->
                            <div class="mobile-nav-toggler"><span class="icon flaticon-menu"></span></div>
                            <!-- Main Menu -->
                            <nav class="main-menu navbar-expand-md navbar-light">
                                <div class="navbar-header">
                                    <!-- Togg le Button -->      
                                    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                                        <span class="icon flaticon-menu"></span>
                                    </button>
                                </div>

                                <div class="collapse navbar-collapse clearfix" id="navbarSupportedContent">
                                    <ul class="navigation clearfix">
                                        <li class="@if( (isset($currentPage) and ($currentPage == '/') ) ) current @endif""><a href="/">Home</a></li>
                                        <li class="dropdown @if( (isset($currentPage) and ($currentPage == 'solutions') ) ) current @endif"><a href="#">Solutions</a>
                                            <ul>
                                                <li><a href="/solutions/banking">Banking</a></li>
                                                <li><a href="/solutions/e-commerce">E-Commerce</a></li>
                                                <li><a href="/solutions/ssl-authorities">SSL Authorities</a></li>
                                            </ul>
                                        </li>
                                        <li class="@if( (isset($currentPage) and ($currentPage == 'price') ) ) current @endif"><a href="/price">Pricing</a></li>
                                        <li class="@if( (isset($currentPage) and ($currentPage == 'press') ) ) current @endif"><a href="/press">Press</a></li>
                                        <li class="@if( (isset($currentPage) and ($currentPage == 'contact') ) ) current @endif"><a href="/contact">Contact</a></li>
                                    </ul>
                                </div>
                            </nav>
                            <div class="option-box clearfix">
                                <div class="btn-box">
                                    @if( isset($_session->id) )
                                        <a href="/dashboard" class="theme-btn btn-style-one"><span class="txt">Go to Dashboard</span></a>
                                    @else
                                        <a href="/account/login" class="theme-btn btn-style-one"><span class="txt">Register/Login</span></a>
                                    @endif
                                    <a href="/free-demo" class="theme-btn btn-style-two"><span class="txt">Request A Demo</span></a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--End Header Upper-->

            <!-- Mobile Menu  -->
            <div class="mobile-menu">
                <div class="menu-backdrop"></div>
                <div class="close-btn"><span class="icon flaticon-plus"></span></div>

                <nav class="menu-box">
                    <div class="nav-logo" style="max-width: 60%;"><a href="/"><img src="/colin/images/pci_logo_invert.png?v={!!env('APP_STATIC_VERSION')!!}" alt="" title=""></a></div>
                    <ul class="navigation clearfix"><!--Keep This Empty / Menu will come through Javascript--></ul>
                </nav>
            </div><!-- End Mobile Menu -->
        </header>
        <!-- End Main Header -->

        <main>
            <div class="container">
                <div style="padding:80px 0 40px 0">&nbsp;</div>
                <form method="POST" action="">
                    
                    <div class="form-group">
                        <label for="one_time_password" class="col-md-12 control-label"> - Two Factor Authentication</label>
                    </div>
                    <div class="form-group">
                        <input id="one_time_password" class="form-control" name="one_time_password" required autofocus>
                    </div>
                    <div class="form-group">
                        <label style="font-size:12px;">2FA has been enabled for your account! Please Use Code via Google Authenticator</label>
                    </div>
                    <div class="form-group">
                        <div class="col-md-6 col-md-offset-4">
                            <button type="submit" class="btn btn-primary">
                                Continue
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </main>

        @include('layouts.production.site.footer')
    </div>

    <div class="scroll-to-top scroll-to-target" data-target="html"><span class="fa fa-angle-up"></span></div>
</body>

I do not know the reason but I can't get any error on neither session nor cookie. Any help would be pretty good.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2SG7v0g
via IFTTT

Aucun commentaire:

Enregistrer un commentaire