A
A
Abc Edc2015-08-06 15:36:42
Laravel
Abc Edc, 2015-08-06 15:36:42

How does laravel Auth controller know which field to encrypt?

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Auth;
use Illuminate\Support\Facades\Redirect;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

class AuthController extends Controller
{

  use AuthenticatesAndRegistersUsers, ThrottlesLogins;

  
  public function __construct()
  {
    $this->middleware('guest', ['except' => 'getLogout']);
  }


  
  protected function validator(array $data)
  {
    return Validator::make($data, [
      'login' => 'required|max:255',
      'email' => 'required|email|max:255|unique:users',
      'pass' => 'required|confirmed|min:6',
    ]);
  }

  
  protected function create(array $data)
  {
    $user=new User;
    $user->login= $data['login'];
    $user->email=$data['email'];
    $user->pass=bcrypt($data['pass']);
    $user->save();
  }

  public function authenticate(Request $request)
  {	$login=$request->input('login');
    $pass=$request->input('pass');
    $validator = Validator::make($request->all(), [
      'login'=>'required',
      'pass'=>'required'
    ]);
    if ($validator->fails()) {
      return Redirect::to('auth/login')
        ->withErrors($validator)
        ->withInput();
    } else {
      if (Auth::attempt(['login' => $login , 'pass' => $pass ])) {
        return redirect()->intended('home');
      }
      return Redirect::to('auth/login')
        ->withErrors('Wrong login/pass');
    }
  }

}

Everything is standard. But due to the fact that I changed (or not because of this) password to pass and email to login
All the time throws an error. Still, how does it know that pass is the password that is somewhere by default. So this is where the problem lies? and how to solve it then? or all the same, he somehow magically finds out what the password is from this

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2015-08-06
@miraage

https://github.com/laravel/framework/blob/5.1/src/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question