Asked  2 Years ago    Answers:  5   Viewed   118 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
 
1

After re-reading the docs, it is clear that this is intended behaviour. The docs say

As an alternative to mocking, you may use the Event facade's fake method to prevent all event listeners from executing.

As described in a comment, I have to create two tests. One for making sure that the event has been fired and contains the expected data and a second one for making sure that the event listeners get fired.

So, first Test:

Event::fake();

$order = factory(Order::class)->make();

event(new PaymentWasCompleted($order));

Event::assertDispatched(PaymentWasCompleted::class, function ($e) use ($order) {
    return $e->order->id === $order->id;
});

Second test:

Queue::fake();

$order = factory(Order::class)->make();

event(new PaymentWasCompleted($order));

Queue::assertPushed(GenerateInvoiceJob::class, function ($job) use ($order) {
    return $job->order->id === $order->id;
});

As expected, this tests pass.

Saturday, December 3, 2022
 
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
 
3

I've tried the following code , it gives the functionality in right manner.However I failed to give the highlighting effect to the button upon clicking on it. here is the code :

{
    if (FBSDKAccessToken.currentAccessToken() != nil)
        {
            // if user logged in then handleTap func will run instead of button functionality
            let tap = UITapGestureRecognizer(target: self, action: "handleTap:")
            self.btnSignUpwithFaceBook.addGestureRecognizer(tap)

        }

        else
        {
            let loginView : FBSDKLoginButton = FBSDKLoginButton()
            self.view.addSubview(loginView)
            loginView.center = self.btnSignUpwithFaceBook.center
            loginView.frame.size.width = self.btnSignUpwithFaceBook.frame.width
            loginView.frame.size.height = self.btnSignUpwithFaceBook.frame.height
            loginView.frame.origin.x = self.btnSignUpwithFaceBook.frame.origin.x
            loginView.frame.origin.y = self.btnSignUpwithFaceBook.frame.origin.y

            for subView in loginView.subviews
            {
                subView.removeFromSuperview()
            }
            loginView.layer.shadowColor = UIColor.clearColor().CGColor

            loginView.setBackgroundImage(nil, forState: UIControlState.Normal)
            loginView.setBackgroundImage(nil, forState: UIControlState.Application)
            loginView.setBackgroundImage(nil, forState: UIControlState.allZeros)
            loginView.setBackgroundImage(nil, forState: UIControlState.Highlighted)
            loginView.setBackgroundImage(nil, forState: UIControlState.Reserved)
            loginView.setBackgroundImage(nil, forState: UIControlState.Selected)

            loginView.setImage(nil, forState: UIControlState.Normal)
            loginView.setImage(nil, forState: UIControlState.Application)
            loginView.setImage(nil, forState: UIControlState.allZeros)
            loginView.setImage(nil, forState: UIControlState.Highlighted)
            loginView.setImage(nil, forState: UIControlState.Reserved)
            loginView.setImage(nil, forState: UIControlState.Selected)

            loginView.backgroundColor = UIColor.clearColor()
            // just for test
            self.btnSignUpwithFaceBook.layer.borderWidth = 1
            self.btnSignUpwithFaceBook.layer.borderColor = UIColor.whiteColor().CGColor
            loginView.layer.backgroundColor = UIColor.clearColor().CGColor

            loginView.readPermissions = ["public_profile", "email", "user_friends"]
            loginView.delegate = self
            loginView.setTranslatesAutoresizingMaskIntoConstraints(false)

            var constX = NSLayoutConstraint(item: loginView, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: self.btnSignUpwithFaceBook, attribute: NSLayoutAttribute.CenterX, multiplier: 1, constant: 0)
            view.addConstraint(constX)

            var constY = NSLayoutConstraint(item: loginView, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: self.btnSignUpwithFaceBook, attribute: NSLayoutAttribute.CenterY, multiplier: 1, constant: 0)
            view.addConstraint(constY)

            let views = ["loginView": loginView]

            var constH = NSLayoutConstraint.constraintsWithVisualFormat("H:[loginView(57)]", options: NSLayoutFormatOptions(0), metrics: nil, views: views)
            view.addConstraints(constH)


            var constW = NSLayoutConstraint.constraintsWithVisualFormat("V:[loginView(281)]", options: NSLayoutFormatOptions(0), metrics: nil, views: views)

            view.addConstraints(constW)

}

actually the major problem is that facebookLogInButton is customized class for FBSDK and swift doesn't consider it as uiButton that's why no highlighting property appears. So the point I'm aiming to find it by your help guys is to find a way that let's facebookLoginButton to be considered as uiButton in swift.

Saturday, September 24, 2022
 
dascs
 
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 :
 

Browse Other Code Languages