Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.70 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.  var config = {
  96.     apiKey: "",
  97.     authDomain: "",
  98.     databaseURL: "",
  99.     projectId: "",
  100.     storageBucket: "",
  101.     messagingSenderId: ""
  102.   };
  103.   firebase.initializeApp(config);
  104.  
  105.   const txtEmail = document.getElementById('correo');
  106. const txtPassword = document.getElementById('pass');
  107. const btnLogin = document.getElementById('login');
  108. console.log('before');
  109. btnLogin.addEventListener('click', e => {
  110.     console.log('listener');
  111.     const email = txtEmail.value;
  112.     const pass = txtPassword.value;
  113.     const auth = firebase.auth();
  114.  
  115.     const promesa = auth.signInWithEmailAndPassword(email,pass);
  116.     promesa.catch(e => location.href = "admin/error.php");
  117.  
  118. });
  119.  
  120.  
  121. firebase.auth().onAuthStateChanged(firebaseUser => {
  122.     if (firebaseUser) {
  123.             location.href="../../home";
  124.         }
  125. });
  126.  
  127.  
  128.   function IngresoGoogle() {
  129.     if (!firebase.auth().currentUser) {
  130.         var provider = new firebase.auth.GoogleAuthProvider();
  131.  
  132.         provider.addScope('https://www.googleapis.com/auth/plus.login');
  133.         firebase.auth().signInWithPopup(provider).then(function(result){
  134.             var token = result.credential.accessToken;
  135.             var user = result.user;
  136.             var name = result.user.displayName;
  137.             var correo = result.user.email;
  138.             var foto = result.user.photoURL;
  139.             var red = 'Google';
  140.             location.href = 'login/index.php?name=' + name + '&correo=' + correo + '&foto=' + foto + '&red=' + red;
  141.         }).catch(function(error){
  142.             var errorCode = error.code;
  143.             if (errorCode === 'auth/account-exist-with-diferent-credential') {
  144.                 alert('El usuario ya existe');
  145.             }
  146.         });
  147.     }else{
  148.         firebase.auth().signOut();
  149.     }
  150.   }
  151.  
  152.   document.getElementById('btn-Google').addEventListener('click',IngresoGoogle,false);
  153. </script>
  154. @endsection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement