laravel 4直接登录后注销?

时间:2016-01-16 14:41:15

标签: laravel authentication login laravel-4 login-attempts

我尝试通过电子邮件和密码登录 auth ::尝试成功登录但是当登录后重定向到链接它自己注销,在localhost上一切都很好但是当我在主机上传我的项目时出现了这个问题

登录功能

public function login(){

            $validator=Validator::make(Input::all(),array(

                    'email'     =>  'email|required',

                    'password'  =>  'required'

                ));



            if($validator->fails()){

                $messages = $validator->messages();

                $msg='';

                foreach ($messages->all() as $message)

                {

                    $msg .= "<li>".$message."</li><br />";

                }

                return $msg;

            }

            else{

                $email = Input::get('email');

                $password = Input::get('password');

                $user=Auth::attempt(array(

                    'email' =>  $email,

                    'password'  =>  $password,

                    'activated' =>  1

                ),true);
                //die(Auth::user()->rule);
                if($user){
                    //Auth::login($user);
                    //die('1111111111');
                    return 1;

                }

                else{

                    return "يوجد خطأ فى البريد الإلكترونى أو كلمة المرور";

                }
                //die('11111111111111111');
            }

        }

模型

<?php
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
use Mmanos\Social\SocialTrait;

class User extends Eloquent implements UserInterface, RemindableInterface
{
    use SocialTrait;

     protected $fillable = array('username','password','rule', 'email','active','phone','address','add_info','image','first_name','sec_name','country','area','baqah_id');
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'users';

    public static function is_admin(){
        if(Auth::user()->rule=='admin'){
            return true;
        }
        return false;
    }

    /*
    one to one relation 
    */
    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = array('password');

    /**
     * Get the unique identifier for the user.
     *
     * @return mixed
     */
    public function getAuthIdentifier()
    {
        return $this->getKey();
    }

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


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

    public function setRememberToken($value)
    {
        $this->remember_token = $value;
    }

    public function getRememberTokenName()
    {
        return 'remember_token';
    }
}

&GT;

0 个答案:

没有答案
相关问题