Viewed   124 times

I am currently working on my first laravel project and I am facing a problem.

If you have experience with laravel you probably know that by calling php artisan make:auth you will get a predefined mechanism that handles login and registration.

This mechanism is set to understand a couple of commonly used words in order to automate the whole procedure.

The problem that occurs in my case is that I am using oracle db and it won't let me have a table column with the name of password because its a system keyword and it throws errors when trying to insert a user.

So far, I have tried to change my password column to passwd and it worked in my registration form as expected. The User row was successfully inserted and my page was redirected to /home.

But when I try to logout and then relogin, I get this error telling me that my credentials are not correct:

As for my code, I have changed my RegisterController.php so that it takes username instead of email

protected function validator(array $data)
{
    return Validator::make($data, [
        'username' => 'required|max:50|unique:ECON_USERS',
        'passwd' => 'required|min:6|confirmed',
    ]);
}

protected function create(array $data)
{
    return User::create([
        'username'   => $data['username'],
        'passwd'     => bcrypt($data['passwd'])
    ]);
}

The User $fillable

protected $fillable = [
    'username', 'passwd'
];

I am guessing that Auth is trying to authenticate with email and not username or that Auth is searching for password and not passwd.

 Answers

3

For having username instead of email, you can overwrite username() in your LoginController.php

/**
 * Get the login username to be used by the controller.
 *
 * @return string
 */
public function username()
{
    return 'username';
}

And for passwd instead of password, you can do define an accessor in your AppUser.php

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

login.blade.php : Replace email input with username but do not change the name of the input for password.

Monday, August 22, 2022
1

Recommended approach if you put here only methods (not classes):

  1. Create file anywhere you want
  2. In composer.json make sure you add this file to files key inside autoload like this:

    "autoload": {
        // here other autoload things
    
        "files": ["app/Helpers/AnythingHelper.php"]
    },
    
  3. Run composerdump-autoload`

For classes obviously you should use standard PSR-4 autoloading

Sunday, October 23, 2022
 
dvir
 
2

The "illuminate/html" component is no more supported by Laravel and is not compatible with the 5.2 version.

You can replace it with laravelcollective/html

You have to:

  • remove the reference of "illuminate/html": "^5.0@dev", from composer.json

  • add "laravelcollective/html": "5.1.*" (or the version you want)

  • run composer update to update the dependecies (this will remove your "illuminate/html" component and install the "laravelcollective/html" component

Now you have to replace your HTML service provider with:

 'providers' => [
    CollectiveHtmlHtmlServiceProvider::class,
  ],

and the facades:

  'aliases' => [
      'Form' => CollectiveHtmlFormFacade::class,
      'Html' => CollectiveHtmlHtmlFacade::class,
  ],
Wednesday, December 21, 2022
 
showdev
 
3

As you can see in the authentication quickstart from the Laravel's Documentation at the "Username Customization" paragraph, you can easily customize the data that the user use to authenticate :

By default, Laravel uses the email field for authentication. If you would like to customize this, you may define a username method on your LoginController :

public function username()
{
    return 'username';
}
Thursday, October 27, 2022
 
dan1111
 
4

The correct way to override a base class's property is:

static TestControl() {

    FooProperty.OverrideMetadata(
        typeof(TestControl),
        new FrameworkPropertyMetadata(67)
    );
}

EDIT:

AddOwner is meant to share the same DependencyProperty across types that are not related (i.e. the TextProperty of TextBox and TextBlock).

Monday, November 7, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :