CoderFunda
  • Home
  • About us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • About us
  • Home
  • Php
  • HTML
  • CSS
  • JavaScript
    • JavaScript
    • Jquery
    • JqueryUI
    • Stock
  • SQL
  • Vue.Js
  • Python
  • Wordpress
  • C++
    • C++
    • C
  • Laravel
    • Laravel
      • Overview
      • Namespaces
      • Middleware
      • Routing
      • Configuration
      • Application Structure
      • Installation
    • Overview
  • DBMS
    • DBMS
      • PL/SQL
      • SQLite
      • MongoDB
      • Cassandra
      • MySQL
      • Oracle
      • CouchDB
      • Neo4j
      • DB2
      • Quiz
    • Overview
  • Entertainment
    • TV Series Update
    • Movie Review
    • Movie Review
  • More
    • Vue. Js
    • Php Question
    • Php Interview Question
    • Laravel Interview Question
    • SQL Interview Question
    • IAS Interview Question
    • PCS Interview Question
    • Technology
    • Other

17 May, 2022

Laravel 9: change table and fields for authentication and login

 Programing Coderfunda     May 17, 2022     Laravel, php     No comments   

 0

I have changed the table and the Laravel Breeze fields for authentication to some custom ones. It looks fine but in AuthenticatedSessionController.php while I get Auth::Check() == true when it executes return redirect()->intended(RouteServiceProvider::HOME); I get redirected to login page without any error message.

AuthenticatedSessionController.php

public function store(LoginRequest $request)
{
    $request->authenticate();

    $request->session()->regenerate();
    //Auth::Check() == true here I get true.

    return redirect()->intended(RouteServiceProvider::HOME);
}

I have only modified $user->getAuthPassword to return the new field for password and the protected $table variable (and fillables) in user model to show the new table.



Answer

0

Did you specify the protected $primaryKey if your custom table primary key is not 'id'. In my case, it redirected me to dashboard when I specify the $primaryKey.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Would like a php version of php 8.1 for a specific virtual website

 Programing Coderfunda     May 17, 2022     Laravel, php     No comments   

 

Answer

0

If using Debian/Ubuntu:

apt -y install software-properties-common
add-apt-repository ppa:ondrej/php
apt -y install php8.1

CentOS:

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

dnf remove php* -y
dnf module list reset php -y
dnf module enable php:remi-8.1
dnf install php

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Laravel 9 - Passport custom api for Authorization

 Programing Coderfunda     May 17, 2022     php     No comments   

 In my application, I am using Passport for Authentication. I have created a Password grant client for generating access tokens for our mobile and web app.

Now I have to add a third-party client that can access some of our resources. For this, I created a client.

Now for a user that can authorize this third-party client for access the resources on behalf of him have to come to our website and login and then needs to authorize to get the authorization code. This I want to do in our own web app. For that, I need to create an API where as a request I will receive client_id, client_secret, grant_type, redirect_url, scopes, etc and return the authorization code.

But nowhere I see an option to create a custom API for generating the authorization code?

-- Edited

https://laravel.com/docs/9.x/passport#approving-the-request

As mentioned here Passport will automatically display a template to the user allowing them to approve or deny the authorization request

We have our own SPA, we can't use the template provided by Passport. Somehow we need to override this and create an API that our SPA can call for authoring or denying the authorization request.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

After Login/Signup, Laravel returns "419 PAGE EXPIRED."

 Programing Coderfunda     May 17, 2022     php     No comments   

 

Answer

0

I hope you have already fixed this. But in case you didn't or someone else has the same problem.The answer should be to edit session.php in config file changing 'same_site' to null. Let me know if this helps.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Downloading 1000s of images using php , how to bypass blank images

 Programing Coderfunda     May 17, 2022     php     No comments   

 

 Answer

1

is what i have done the best method for what i'm trying to achieve ?

Answers to such kind of questions are generally based on your explanation of 'best'. Since you said you have very little knowledge of php, I just guess you want a simple approach, and the simplest approach I can find is:

file_put_contents($img, file_get_contents($url));

Notice that you should set allow_url_fopen = On and enable openssl (extension=openssl) in php.ini.

Here is a full example:

foreach ($espn_ar as $value) {
    $url = "https://a.espncdn.com/i/headshots/nfl/players/full/$value.png";
    $img = "images/$value.png";
    $content = file_get_contents($url);
    file_put_contents($img, $content);
}

when using the desktop app it doesn't download a blank image if the url path doesn't contain an image , however using the php method it does download a blank image if one of the url paths doesn't contain any image , so how can i add something to not download a blank png file , or only download files over 1kb , or delete all files 1kb or smaller after all files downlaoded, not sure what is best way to handle that.

Because I can't check all the URLs, I guess these blank images may be caused by 404 error, or the images are really blank. I'll check them all.

    $content = file_get_contents($url);
    
    # download failed
    if($content === false)
        continue;
    
    # 404 error
    if(strpos($http_response_header[0], '404 Not Found') !== false)
        continue;

    # size < 1kb
    if(strlen($content) < 1024)
        continue;

    file_put_contents($img, $content);
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

Order payment status check failing when waiting for payment status through a webhook

 Programing Coderfunda     May 17, 2022     php     No comments   

 

 Answers

0

Looks like your your do/while conditional checks the get_status() method's return value against un-prefixed strings "pending" and "failed", while the update_status() method in the second block of code is presumably setting the class variable for order status to stings that all include a "wc-" prefix (wc-failed, wc-processing, wc-completed etc).

Change $loopOrder->get_status() == "pending" to $loopOrder->get_status() == "wc-pending" and $loopOrder->get_status() == "failed" to $loopOrder->get_status() == "wc-failed" in your first block.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

What would be a proper way to handle tokens in monolith application?

 Programing Coderfunda     May 17, 2022     php     No comments   

 

1 Answer

1

The users of your application never have to be mixed up / mistaken with your foreign API. You can and should provide you own mechanism (i.e. tokens) to authenticate any users. If users are authenticated the external API is used, else an error-message could be provided by your application.

As users also fill several different form it's quite possible that you save some user-data. If every user has own authentication credentials it's easy and much more secure to provide only the user's own data. If you use for every user the same authentication token in your own application you might get the situation that one user can see data from another user.

So see it like this:
You / your application is the user of the external API, therefore you need only one authenticqation token for it. Your application users use the external API as a service and as that you should provide it in your app. The data though that are provided to the service might differ from user to user.

Example payment application:
The API is always the same, you as developer get an API key, but the payments are for every user of your application differently. As developer you might never even able to see, store or track the user-data that are exchanged between the foreign service and the user, but your app serves as hub and provides perhaps also some products or services that are considered in any payments.

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Posts Older Posts Home

Meta

Popular Posts

  • Vue.js Tutorial
    Vue.js Tutorial Vue.js tutorial provides basic and advanced concepts of Vue.js. Our Vue.js Tutorial is designed for beginners and profession...
  • Automaticall generate pass through to child object function
    I would like to automatically forward a function call to a child in python, so that the parent class has said function and then forwards the...
  • Generalization
    Generalization Generalization is like a bottom-up approach in which two or more entities of lower-level levels combine to form a higher-leve...
  • Blade Component to Serve Images and Download Files
      Smart   makes it possible to serve images and download files from any location, including Laravel disks within a Laravel application. It e...
  • I made this code, but I am not understanding how JavaScript is handling the swapping??? (I have seen this before in an article but didnt explain)
    What is the name or official term of what I want to understand below in JavaScript?? I have never been able to find a clear article expla...

Categories

  • Ajax (26)
  • Bootstrap (30)
  • DBMS (42)
  • HTML (12)
  • HTML5 (45)
  • JavaScript (10)
  • Jquery (34)
  • Jquery UI (2)
  • JqueryUI (32)
  • Laravel (1017)
  • Laravel Tutorials (23)
  • Laravel-Question (6)
  • Magento (9)
  • Magento 2 (95)
  • MariaDB (1)
  • MySql Tutorial (2)
  • PHP-Interview-Questions (3)
  • Php Question (13)
  • Python (36)
  • RDBMS (13)
  • SQL Tutorial (79)
  • Vue.js Tutorial (69)
  • Wordpress (150)
  • Wordpress Theme (3)
  • codeigniter (108)
  • oops (4)
  • php (853)

Social Media Links

  • Follow on Twitter
  • Like on Facebook
  • Subscribe on Youtube
  • Follow on Instagram

Pages

  • Home
  • Contact Us
  • Privacy Policy
  • About us

Blog Archive

  • July (4)
  • September (100)
  • August (50)
  • July (56)
  • June (46)
  • May (59)
  • April (50)
  • March (60)
  • February (42)
  • January (53)
  • December (58)
  • November (61)
  • October (39)
  • September (36)
  • August (36)
  • July (34)
  • June (34)
  • May (36)
  • April (29)
  • March (82)
  • February (1)
  • January (8)
  • December (14)
  • November (41)
  • October (13)
  • September (5)
  • August (48)
  • July (9)
  • June (6)
  • May (119)
  • April (259)
  • March (122)
  • February (368)
  • January (33)
  • October (2)
  • July (11)
  • June (29)
  • May (25)
  • April (168)
  • March (93)
  • February (60)
  • January (28)
  • December (195)
  • November (24)
  • October (40)
  • September (55)
  • August (6)
  • July (48)
  • May (2)
  • January (2)
  • July (6)
  • June (6)
  • February (17)
  • January (69)
  • December (122)
  • November (56)
  • October (92)
  • September (76)
  • August (6)

Loading...

Laravel News

Loading...

Copyright © CoderFunda | Powered by Blogger
Design by Coderfunda | Blogger Theme by Coderfunda | Distributed By Coderfunda