Автоматическое форматирование текста на JTextArea

Позвольте мне упростить ваш процесс:

Auth\registerController

protected function create(array $data)
{ 
        $user = User::create([
            'name' => $data['name'],
            'lname' => $data['lname'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
            'u_type'=> $data['u_type'],
            'token' => str_random(25),
            'avatar'=> str_random(5),
            'approved'=> $data['u_type'] == 'D' ? true: false
        ]);
}

. Одна вещь, которая, как я полагаю, должен быть такой: в своей базе данных установите столбец «одобрен» по умолчанию к false и не может быть недействительным. Еще одна вещь, которая может произойти, состоит в том, что у вас может не быть переменной «одобрено» в $fillable в модели пользователя.

Ваша модель пользователя должна иметь что-то вроде этого:

$fillable = ['name','lname','email','password','u_type','token','avatar','approved'];
// $guarded = ['password']; or even $hidden = ['password']

https://laravel.com/docs/5.6/authentication#included-authenticating

LoginController

protected function authenticated(Request $request){

    $user = User::where('email','=', $request->email)->first();

    //There is no need to validate the token, unless you really want it to
    if($user->approved) {
      Auth::attempt($user); 
      //Or Auth::login($user);
      return redirect()->back();
      //Redirect back may redirect you to a place where you may not want it, depending on the url's that you hit previously when loading a page, a redirect to a certain url, usually home, is more effective
    }
    else{ 
        //Token will be filled with a random string whenever the account is created, so validation if token is null is really needed.
        //What you may need is to save information about if an email was or not sent to the user and if it did sent, it shows different errors.
        return back()->with('info','Account not approved yet, please contact admin');   
        //No need to Auth::logout if he didn't managed to login. Either he's logged or he's not
    }
  }

0
задан Andrew Thompson 19 January 2019 в 04:47
поделиться

1 ответ

0
ответ дан xehpuk 19 January 2019 в 04:47
поделиться
Другие вопросы по тегам:

Похожие вопросы: