Laravel4 , Auth

Programovacie jazyky, rady, poradňa...
mnichovcan
Medium Expert
Medium Expert
Príspevky: 97
Registrovaný: 17 mar 2011, 23:03

Laravel4 , Auth

Príspevok od používateľa mnichovcan »

Zdravím ,

dúfam že tu niekto ovláda Laravel lebo som v koncoch hneď na začiatku :)

Snažím sa spraviť Prihlasovanie / Registráciu . Registrácia funguje ale ten login nie.

Toto je metoda na Login

Kód: Vybrať všetko

     public function postLogin(){
 


   		$input = Input::all();
    
		  $rules = array('meno' => 'required','password' => 'required' );

        $val = Validator::make($input, $rules);

         if ($val->fails()){

           return Redirect::to('/')->withErrors($val);  

        }else{

        	  $meno = $input['meno'];
            $password = $input['password'];

          

         	if (Auth::attempt(Input::only('meno','password'))){

                    echo "ok"; // return Redirect::intended('dash.home');

                  }else{
                  	echo "zle!" ;
                  }
             
              }
          
    }
User Model

Kód: Vybrať všetko

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {



	protected $table = 'users';
    
    protected $fillable =  ['meno','password'];
   

     public $timestamps = false;

    
   
	public function getAuthIdentifier()
	{
		return $this->getKey();
	}

	/**
	 * Get the password for the user.
	 *
	 * @return string
	 */
	public function getAuthPassword()
	{
		return $this->password;
	}


	/**
	 * Get the token value for the "remember me" session.
	 *
	 * @return string
	 */
	public function getRememberToken()
	{
		return $this->remember_token;
	}

	/**
	 * Set the token value for the "remember me" session.
	 *
	 * @param  string  $value
	 * @return void
	 */
	public function setRememberToken($value)
	{
		$this->remember_token = $value;
	}

	/**
	 * Get the column name for the "remember me" token.
	 *
	 * @return string
	 */
	public function getRememberTokenName()
	{
		return 'remember_token';
	}

	/**
	 * Get the e-mail address where password reminders are sent.
	 *
	 * @return string
	 */
	public function getReminderEmail()
	{
		return $this->email;
	}

}
Môj problém je že sa stále vykonáva tá čast ze else

Kód: Vybrať všetko

	if (Auth::attempt(Input::only('meno','password'))){

                    echo "ok"; // return Redirect::intended('dash.home');

                  }else{
                  	echo "zle!" ;   TOTO SA STÁLE VYKONÁVA
                  }
Pozerám do dokumentácie ale stále som nič nezistil.
V DB mám id,meno,password

No vyriešené. To heslo sa muselo ukladať ako hash.
Napísať odpoveď