C
C
Crash2015-02-10 13:50:45
Laravel
Crash, 2015-02-10 13:50:45

Why doesn't authorization work in Laravel?

It seems that I do everything as it should, but there is a jamb with authorization.
So the User model:

class User extends Eloquent implements UserInterface, RemindableInterface {

  use UserTrait, RemindableTrait;

  /**
   * The database table used by the model.
   *
   * @var string
   */
  protected $table = 'users';
  protected $primaryKey = 'id';

  /**
   * The attributes excluded from the model's JSON form.
   *
   * @var array
   */
  protected $hidden = array('password', 'remember_token');
  protected $fillable = array('username', 'email', 'telephone');

  public static $rules = array(
    'username' => 'required|min:2|alpha',
    'email' => 'required|email|unique:users',
    'telephone' => 'required|between:10,12',
    'password' => 'required|alpha_num|between:8,12|confirmed',
    'password_confirmation' => 'required|alpha_num|between:8,12'
  );

}

Controller method:
public function postSignin()
  {
    if(Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password')), true)) {
      return Redirect::to('/')->with('message', 'Добро пожаловать и знакомиться!)');
    }

    return Redirect::to('auth/signin')->with('message', 'Ошибочка вышла! Попробуйте еще раз ;)');
  }

Examination:
@if( Auth::check() )
                Здравствуйте, {{ Auth::user()->username }} !<br/>
                {{ HTML::link('auth/signout', 'Выход') }}
            @else
                {{ HTML::link('auth/signin', 'Вход') }} | {{ link_to('auth/signup', 'Регистрация') }}
            @endif

And more messages:
@if(Session::has('message'))
                <p class="alert">{{ Session::get('message') }}</p>
            @endif

As a result, after a successful authorization attempt and redirection to the main page, it displays
{{ HTML::link('auth/signin', 'Вход') }} | {{ link_to('auth/signup', 'Регистрация') }}

and does not display Session messages. What can be wrong?
UPD: When redirecting, it displays an empty page "I redirecting to ..." for a few seconds and the session is terminated. Who faced this problem, please respond
UPD2: I solved the problem by simply rewriting the entire code.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2015-02-20
@akserdin

Have you changed the session settings in the session.php file? If not changed, then test with other session drivers. And also check if the group has write permissions (775) for the /app/storage folder.
And throw out the entire Session::all(), and see what it has.

V
Vyacheslav Barsukov, 2015-02-22
@slavabars

Show what fields you have in the database.
Gathered the password in hash?
Either the token column is missing in the database or the password is not for the hash

0
0xD34F, 2017-09-30
@PPP2

So after all according to the link resulted by you all is written. Use the direction parameter:

$('#toggle').toggle('slide', {
  direction: 'up'
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question