Question: Check for the status and the verified email in laravel

Question

Check for the status and the verified email in laravel

Answers 1
Added at 2017-01-03 14:01
Tags
Question

In my laravel project I am checking for status and verified_email after login.but shows the error for username password not match only do not checking the error code which is going after login and loading the page continuously.

sessioncontroller

<?php
namespace App\Http\Controllers;

use Request;
use Response;
//----models--------
use App\Site;
use App\Jobs;


use Auth;
use DB;
use Validator;
use Redirect; 

use Illuminate\Support\MessageBag;
class SessionController extends Controller {

    public function index(){
        return Redirect::to('login');
    }
    public function store()
    {
             $input = Request::only('username', 'email', 'password');
             $credentials = [
                 'username' => Request::get('username'),
                 'password' => Request::get('password')
             ];

            if (!Auth::attempt($credentials))
            {
                return Redirect::back()->with('alert-danger', 'Username or password do not match.');
            }
            else 
            {

                if (Auth::user()->verified_email != 1) {
                    Auth::logout();
                    return Redirect::back()->with('alert-danger', 'Please verify your email.');
                }

                if (Auth::user()->status != 'A') {
                    Auth::logout();
                    return Redirect::back()->with('alert-danger', 'Your Account is disabled.Please contact your Administrator.');
                }

                $credentials_last_login = [
                    'last_login_at' => '',
                    'username' => array_get('username', $input, ' '),
                    'password' => array_get('password', $input, ' ')
                ];
                if (Auth::attempt($credentials_last_login))
                {
                    return redirect('/change_password');
                }
                else
                {
                    return redirect('/properties');
                }
            }
    }
}

It gives an error alert when username password not match but do not when verified_email is not 1 and when status is not Active instead of showing the error just load it.

Answers to

Check for the status and the verified email in laravel

nr: #1 dodano: 2017-01-03 15:01

Your password is being stored as a hash but I think your calling it plain - try:

'password' => Hash::make($request->password)
Source Show
◀ Wstecz