Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.60 KB | None | 0 0
  1. @extends('layouts.template')
  2.  
  3. @section('style')
  4.  
  5. @endsection
  6. @section('content')
  7.     <div class="login-bg pattern-7" style="height: 100em">
  8.         <div class="container">
  9.             <br>
  10.             <br>
  11.             <section class="login-section">
  12.  
  13.                 <div class="card" style="width: 28rem; margin-top: 5em">
  14.                     <div class="card-body">
  15.  
  16.                         <div class="form-horizontal">
  17.  
  18.                         <!--Header-->
  19.                             <div class="form-header bg-unique">
  20.                                 <h3><i class="fa fa-lock"></i> Login:</h3>
  21.                             </div>
  22.  
  23.                             <!--Body-->
  24.                             <div class="md-form">
  25.                                 <i class="fa fa-envelope prefix grey-text"></i>
  26.                                 <input type="text" name="email" id="correo" class="form-control form-control-lg">
  27.                                 <label for="defaultForm-email">E-mail</label>
  28.                                 @if ($errors->has('email'))
  29.                                     <span class="help-block">
  30.                                     <strong>{{ $errors->first('email') }}</strong>
  31.                                 </span>
  32.                                 @endif
  33.                             </div>
  34.  
  35.                             <div class="md-form">
  36.                                 <i class="fa fa-lock prefix grey-text"></i>
  37.                                 <input type="password" name="password" id="pass" class="form-control form-control-lg">
  38.                                 {{--<label for="defaultForm-pass" class="active">Password</label>--}}
  39.                                 <label for="defaultForm-pass">Password</label>
  40.                                 @if ($errors->has('password'))
  41.                                     <span class="help-block">
  42.                                     <strong>{{ $errors->first('password') }}</strong>
  43.                                 </span>
  44.                                 @endif
  45.                             </div>
  46.  
  47.                             <div class="text-center">
  48.                                 <button id="login" class="btn btn-unique waves-effect waves-light">Iniciar Sesión</button>
  49.                             </div>
  50.                 <div class="form-group">
  51.                 <button id="btn-Google" class="btn btn-danger btn-lg btn-block"><i class="fa fa-google"></i> Google</button>
  52.                 </div>
  53.                         </div>
  54.  
  55.                     </div>
  56.  
  57.                     <!--Footer-->
  58.                     <div class="modal-footer">
  59.                     {{--<div class="options">
  60.                     <p>Not a member? <a href="#">Sign Up</a></p>
  61.                     <p>Forgot <a href="{{ url('/password/email') }}">Password?</a></p>
  62.                         <a class="dropdown-item waves-effect waves-light" href="{{ url('/password/email') }}"
  63.                            onclick="event.preventDefault();
  64.                                                     document.getElementById('password-form').submit();">
  65.                             Olvidó su contraseña?</a>
  66.                         <form id="password-form" action="{{ url('/password/reset') }}" method="GET"
  67.                               style="display: none;">
  68.                         {{ csrf_field() }}
  69.                         </form>
  70.                     </div>--}}
  71.                     </div>
  72.  
  73.                 </div>
  74.  
  75.  
  76.             </section>
  77.  
  78.         </div>
  79.     </div>
  80.     {{--<div class="col-md-6">--}}
  81.  
  82.     {{--<div class="view">--}}
  83.     {{--<img src="https://mdbootstrap.com/img/Photos/Others/nature-sm.jpg" class="img-fluid" alt="">--}}
  84.     {{--<div class="mask pattern-8 flex-center waves-effect waves-light">--}}
  85.     {{--<p class="white-text">.pattern-8</p>--}}
  86.     {{--</div>--}}
  87.     {{--</div>--}}
  88.  
  89.     {{--</div>--}}
  90. @endsection
  91.  
  92. @section('jquery')
  93. <script src="https://www.gstatic.com/firebasejs/4.6.0/firebase.js"/></script>
  94. <script type="text/javascript">
  95. console.log('cy');
  96.  
  97. var config = {
  98.     //ño
  99. };
  100.   firebase.initializeApp(config);
  101.  
  102.   const txtEmail = document.getElementById('correo');
  103. const txtPassword = document.getElementById('pass');
  104. const btnLogin = document.getElementById('login');
  105. console.log('before');
  106. btnLogin.addEventListener('click', e => {
  107.     console.log('listener');
  108.     const email = txtEmail.value;
  109.     const pass = txtPassword.value;
  110.     const auth = firebase.auth();
  111.  
  112.     const promesa = auth.signInWithEmailAndPassword(email,pass);
  113.     promesa.catch(e => location.href = "admin/error.php");
  114.  
  115. });
  116.  
  117.  
  118. firebase.auth().onAuthStateChanged(firebaseUser => {
  119.     if (firebaseUser) {
  120.             location.href="../../home";
  121.         }
  122. });
  123.  
  124.  
  125.   function IngresoGoogle() {
  126.     if (!firebase.auth().currentUser) {
  127.         var provider = new firebase.auth.GoogleAuthProvider();
  128.  
  129.         provider.addScope('https://www.googleapis.com/auth/plus.login');
  130.         firebase.auth().signInWithPopup(provider).then(function(result){
  131.             var token = result.credential.accessToken;
  132.             var user = result.user;
  133.             var name = result.user.displayName;
  134.             var correo = result.user.email;
  135.             var foto = result.user.photoURL;
  136.             var red = 'Google';
  137.             location.href = 'login/index.php?name=' + name + '&correo=' + correo + '&foto=' + foto + '&red=' + red;
  138.         }).catch(function(error){
  139.             var errorCode = error.code;
  140.             if (errorCode === 'auth/account-exist-with-diferent-credential') {
  141.                 alert('El usuario ya existe');
  142.             }
  143.         });
  144.     }else{
  145.         firebase.auth().signOut();
  146.     }
  147.   }
  148.  
  149.   document.getElementById('btn-Google').addEventListener('click',IngresoGoogle,false);
  150. </script>
  151. @endsection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement