InsideDarkWeb.com

Laravel login hecho por mi mismo no funciona (Error 404)

Hice un login por mi cuenta usando Laravel y por alguna razón la ruta NO funciona y da error 404, no sé porque ocurre esto, intente reescribir el login varias veces y sigue con lo mismo

Esto es lo que tengo un index.blade.php

<!DOCTYPE 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.0" />

    <title>Sistema de estudiantes</title>

    <!-- Bootstrap core CSS -->
    <script src="{{ url('/js/jquery.min.js') }}"></script>
    <link rel="stylesheet" type="text/css" href="{{ url('/css/bootstrap-4.5.0-dist/css/bootstrap.css') }}">
    <script src="{{ url('/css/bootstrap-4.5.0-dist/js/bootstrap.js') }}"></script>
    <link rel="stylesheet" type="text/css" href="{{ url('/css/login.css') }}">
</head>

<body>
<center>
<div class="wrapper fadeInDown">
  <div id="formContent">
    <!-- Tabs Titles -->

    <!-- Login Form -->
    <form action="{{url('doLogin')}}">
    {{ csrf_field() }}
      <br></br>
      <h2>Coloque sus datos</h2>
      <br></br>
      <p>Nombre </p><input required type="text" id="name" class="fadeIn second" name="name" placeholder="login">
      @if ($errors->has('name'))
                  <span class="error">{{ $errors->first('name') }}</span>
      @endif 
      <br></br>
      <br></br>
      <p>Email </p><input required type="email" id="email" class="fadeIn second" name="email" placeholder="[email protected]">
      @if ($errors->has('email'))
                  <span class="error">{{ $errors->first('email') }}</span>
      @endif 
      <br></br>
      <br></br>
      <p>Clave </p><input required type="password" id="password" class="fadeIn third" name="password" placeholder="password">
      @if ($errors->has('password'))
                  <span class="error">{{ $errors->first('password') }}</span>
        @endif 
      <br></br>
      <input type="submit" id="entrar" name="entrar" class="fadeIn fourth" value="Entrar">
    </form>

    <!-- Remind Passowrd -->
    <div id="formFooter">
      <a class="underlineHover" href="#">Olvido su clave?</a>
    </div>

  </div>
</div>
</center>
</body>
</html>

Esto es lo que tengo en el UserController.php

<?php

namespace AppHttpControllers;
 
use IlluminateHttpRequest;
use Validator,Redirect,Response;
Use AppUser;
use IlluminateSupportFacadesAuth;
use IlluminateSupportFacadesHash;
use Session;


class UserController extends Controller
{

  public function doLogin()
  {
  // validate the info, create rules for the inputs
  $rules = array(
      'email'    => 'required|email', // make sure the email is an actual email
      'password' => 'required|alphaNum|min:3' // password can only be alphanumeric and has to be greater than 3 characters
  );
  
  // run the validation rules on the inputs from the form
  $validator = Validator::make(Input::all(), $rules);
  
  // if the validator fails, redirect back to the form
  if ($validator->fails()) {
      return Redirect::to('index')
          ->withErrors($validator) // send back all errors to the login form
          ->withInput(Input::except('password')); // send back the input (not the password) so that we can repopulate the form
  } else {
  
      // create our user data for the authentication
      $userdata = array(
          'email'     => Input::get('email'),
          'password'  => Input::get('password')
      );
  
      // attempt to do the login
      if (Auth::attempt($userdata)) {
  
          // validation successful!
          // redirect them to the secure section or whatever
          // return Redirect::to('secure');
          // for now we'll just echo success (even though echoing in a controller is bad)
          echo 'SUCCESS!';
  
      } else {        
  
          // validation not successful, send back to form 
          return Redirect::to('index');
  
      }
  
  }
  }

      public function estudiantes()
      {
   
        if(Auth::check()){
          return view('estudiantes');
        }
         return Redirect::to("index")->withSuccess('Opps! You do not have access');
      }

}

Estas son mis rutas en web.php

Route::get('/', function () {
    return view('index');
});

Route::post('index', array('uses' => '[email protected]'));

Esto es lo que tengo en el model del usuario, User.php

<?php

namespace App;

use IlluminateContractsAuthMustVerifyEmail;
use IlluminateFoundationAuthUser as Authenticatable;
use IlluminateNotificationsNotifiable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

Esta es mi migracion en la base de datos

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->timestamp('email_verified_at')->nullable();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });
}

Me gustaria ver si hay una manera de reescribir el login o hacer que esto funcione porque hace tiempo que no estudio Laravel. Estoy usando Laravel 6.18.25

Stack Overflow en español Asked by Shredder on November 15, 2021

0 Answers

Add your own answers!

Related Questions

INNER JOIN entre dos tablas

1  Asked on December 29, 2020 by miguel-ngel-martn

 

¿Cómo sumar 1 en un array?

2  Asked on December 29, 2020 by armando-sarmiento

   

Sumar tiempos tipo TIME en MySQL

1  Asked on December 28, 2020 by ignacio-fuentes

   

Buscar un input dentro de una tabla datatable

2  Asked on December 28, 2020 by jonathan-cunza

   

Abrir un PDF desde un ListBox en C#

1  Asked on December 27, 2020 by ricardo-vazquez

     

Mostrar y ocultar texto en un Button Tkinter

1  Asked on December 27, 2020 by juan-j-mart

     

Detectar si la pagina esta abierta en otras pestañas con js

1  Asked on December 27, 2020 by julian-baltan

       

Codificar string en javascript

0  Asked on December 27, 2020 by juan

 

GIF como fondo de pantalla JFrame Java

2  Asked on December 26, 2020 by ivan-garcia-ballesteros

     

No puedo coencatarme con la bd

1  Asked on December 26, 2020

   

Filtrar coleccion de mongo por datos de un arreglo

1  Asked on December 26, 2020 by alejandro-castellanos

         

Intento ejecutar e programa pero me da error en PRINTF, no se porque

1  Asked on December 26, 2020 by benjamin-veras

   

Error 1822: Failed to Add foreign key constraint Missing index for constraint

2  Asked on December 25, 2020 by adrian-leon-ortega

   

Error con el campo manytomany Django

1  Asked on December 25, 2020 by nicolas-rivera

       

Ask a Question

Get help from others!

© 2021 InsideDarkWeb.com. All rights reserved.