I am using Socialite for Logging in my users with Facebook. I have done all the processes needed to built the functionality. When I click on "Login with Facebook", it asks for permission and giving permissions on facebook, it redirects me too an error.
This is the error link: http://localhost:8888/under_dev/mytaswir/public/callback?code=AQDupltbruPf7MokV6N-Mlmrcmqu-QFeKyImrMz8Yp3ViAv128lZBDfPS88Su1q60o6EfFL0_KIy2YH7lztGJrdj0ZDUFZDjR2ucMobLpUGyzPc39ABElZBJko3llqB5xehmZxJMuay7lBHybZ7F6AMxrCN2H0bNhPFPts5_v6Zmb0kfFR7H2A-ha4EXbJzTX6Y98SY9G50HWP1v-KqcUt5ozXfsNIldR19O_dMCEunGLTsf2sKLK76ObEwPdERhW-XzhJv-IdzeHU-Ppw91TWYHjWvBbEajwQH9N-p91VjWNaede7zOKfCBYUiOedzlLRDfz1qv9QghjmceULRk-DwldD0hY1nBv_jSJwVtq_FLhQ&state=UkCIOpg6dqle5dStyvbgtc9se0OiLxGwqWUZyTli#=
This is the error screenshot:
It gives out an error: **Class App\Http\Controllers\SocialFacebookAccountService does not exist!
I have made all my Controllers, Service Providers, Aliases, etc.. in the way suggested on this article.
Please help me get rid of this error. I want the programme to log in my Facebook User into the dashboard.
If you want to see the files, see this git commit.
Thanks in advance.
I think you are missing the namespace here: https://github.com/KumarAbhirup/myTaswir/blob/c07b2b5a3dd38f70dd0f26eed2eeb983469993ab/app/Http/Controllers/SocialAuthFacebookController.php#L26
/**
* Return a callback method from facebook api.
*
* #return callback URL from facebook
*/
public function callback(SocialFacebookAccountService $service)
This method belongs to App\Http\Controllers\SocialAuthFacebookController, so when the system tries to resolve the class name SocialFacebookAccountService from that "location", it will result in App\Http\Controllers\SocialFacebookAccountService, and that does not exist.
The class is actually in the namespace \App\Services, so you must also use that in this place:
public function callback(\App\Services\SocialFacebookAccountService $service)
Edit: Fixed error regarding missing leading \, to refer the fully qualified namespace
Related
I'm using this package https://github.com/mpociot/laravel-apidoc-generator to generate api documentation
but i got couple problems:
1- Running requests in the docs always return "unauthenticated" how to configure this in a right way ? i tried to add the login token to apidoc.php in authorization but it didn't work .
some people said i should do this
php artisan api:generate --actAsUserId=1
but it returns
The "--actAsUserId" option does not exist.
2- some request need email as #bodyParam but couldn't find a type of email so i use text which of course fails and return invalid type. how to force type email ?
Thanks in advance, hope i was clear.
try this
/**
* #authenticated <------
* #group MyGrupo
*
*/
class MyController extends Controller{
}
and in your console:
#php artisan apidoc:generate
I'm a former maintainer of laravel-apidoc-generator. The package is no longer supported. Here's the one you should be using: knuckleswtf/scribe.
To pass an auth value in Scribe, you set auth.use_value to the token in your config file. That's it. You can see more in the docs.
The details in the apply.headers section are only used in the HTML docs, not in response calls.
I have just recently started using Sentry on my Laravel 5.1 application.
I see in there docs, and getting started stuff, a reference to capturing user information.
The example they give of passing this in, looks like this:
Raven.setUserContext({
email: 'foo#example.com'
});
Having followed their setup instructions for Laravel, I see no reference for where this could go or any reference in the documentation for how to set this up in a config file or anything for Laravel.
Any ideas on how I could set this up to send user information? Users will always be logged in when using my application.
I realise this question is three months old, so apologies if you’ve already found the answer.
I had the same requirements (log user as part of exceptions in Sentry) so did a little digging myself.
Raven.setUserContext() seems to be a function specific to the JavaScript SDK. The PHP SDK has a set_user_data($id, $email, $data) method on the Raven client that you can use somewhere in your application (most likely in your exception handler before you actually send the exception to Sentry).
Something like this should work:
public function report(Exception $e)
{
// Will only enter if statement if request has a user
if ($user = request()->user()) {
app('sentry')->set_user_data($user->getAuthIdentifier(), $user->email);
}
app('sentry')->captureException($e);
return parent::report($e);
}
I want to implement a data log for attempts against my application. One of this will be when someone without the security rights wants to go to a certain page. For example a normal user trying to go to a url only avaiable for an administrator.
Symfony offers this security annotation:
/**
* #Security("has_role('ROLE_ADMIN')")
*/
And for now I use it to display an error page. But what I would like to do is to send the data to a database in case someone attempts to go in the admin only site recurrently (three or more times in less than a minute). The kind of data I will store is user, in case someone is logged in, IP, timestamp, among others. I already have a service that does the storing I just want to know if there is a way to know that someone is trying to access the page repeatedly without authorization and how to call my service in that case.
I have been looking all over the symfony documentation and couldn't find any information relevant to my problem. I would appreciate your help!
Thanks in advance.
SOLVED
I did what #ShiraNai7 told me to plus this in the service declaration in order to be able to use my other service. Thanks.
app.exception_listener:
class: InnoGames\Bundle\OfficeITBundle\EventListener\ExceptionListener
arguments: [#service_container]
tags:
- { name: kernel.event_listener, event: kernel.exception }
You could create a listner for the kernel.exception event and do your logging there.
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\Response;
public function onKernelException(GetResponseForExceptionEvent $event)
{
$exception = $event->getException();
$request = $event->getRequest();
// do your logging here
}
Also see Symfony docs - How to Create Event Listeners and Subscribers
I'm (we're) creating a package that acts as a core component for our future CMS and of course that package needs some unit tests.
When the package registeres, the first thing it does is set the back/frontend context like this:
class FoundationServiceProvider extends ServiceProvider
{
// ... stuff ...
public function register()
{
// Switch the context.
// Url's containing '/admin' will get the backend context
// all other urls will get the frontend context.
$this->app['build.context'] = request()->segment(1) === 'admin'
? Context::BACKEND
: Context::FRONTEND;
}
}
So when I visit the /admin url, the app('build.context') variable will be set to backend otherwise it will be set to `frontend.
To test this I've created the following test:
class ServiceProviderTest extends \TestCase
{
public function test_that_we_get_the_backend_context()
{
$this->visit('admin');
$this->assertEquals(Context::BACKEND, app('build.context'));
}
}
When I'm running the code in the browser (navigating to /admin) the context will get picked up and calling app('build.context') will return backend, but when running this test, I always get 'frontend'.
Is there something I did not notice or some incorrect code while using phpunit?
Thanks in advance
Well, this is a tricky situation. As I understand it, laravel initiates two instances of the framework when running tests - one that is running the tests and another that is being manipulated through instructions. You can see it in tests/TestCase.php file.
So in your case you are manipulating one instance, but checking the context of another (the one that did not visit /admin and is just running the tests). I don't know if there's a way to access the manipulated instance directly - there's nothing helpful in documentation on this issue.
One workaround would be to create a route just for testing purposes, something like /admin/test_context, which would output the current context, and the check it with
$this->visit('admin/test_context')->see(Context::BACKEND);
Not too elegant, but that should work. Otherwise, look around in laravel, maybe you will find some undocumented feature.
This is a continuation of my last question.
Hi,
I'm implementing, in a Symfony2 application, a custom authentication provider in order to authenticate against the Wordnik REST API.
On application load, no matter what request path, this is the exception I get:
( ! ) Fatal error: Cannot access parent:: when current class scope has no parent in /[..]/WordRot/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php on line 43
You can see the full stacktrace here.
Second to last line in the trace reveals that it is loading the DaoAuthenticationProvider:
18 0.0217 1922792 Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider->__construct( ) ../appDevDebugProjectContainer.php:3071
But none of my configuration refers to that provider, or anything that extends it. My custom provider directly implements the AuthenticationProviderInterface.
So I assume that my configuration is wrong, and somewhere I need to be explicitly setting the WordnikProvider, but I'm not sure where! Research has not provided any clues to this issue.
Any help would be much appreciated!
Files
/app/config/config.yml
/app/config/security.yml
/src/WordRot/PlayBundle/Security/Authentication/Provider/WordnikProvider.php
/src/WordRot/PlayBundle/Security/Authentication/Token/WordnikUserToken.php
/src/WordRot/PlayBundle/Security/Firewall/WordnikListener.php
/src/WordRot/PlayBundle/DependencyInjection/Security/Factory/WordnikFactory.php
the line return $this->authenticationManager->authenticate(new WordnikUserToken($username, $password, $this->providerKey)); in the WordnikListener goes to
Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager (classes.php)
authenticate.
$this->providers are DaoAuthentificationProvider, WordnikProvider and AnonymousAuthentificationProvider.
From the DaoAuthentificationProvider it only uses the method supports($token):
return $token instanceof UsernamePasswordToken && $this->providerKey === $token->getProviderKey();
which returns false so next in line is WordnikProvider.
Oh..misread: the error is in the constructor:
parent::__construct($userChecker, $providerKey, $hideUserNotFoundExceptions); seems to fail. Running PHP 5.4.10 or so I DON'T have an error!!
Either rm -rf vendor and run composer install again or try using a different PHP version!!
A had to create something like this a week ago.
At the and, I created a custom user provider, where I simply call the api and with the response i create the user or not.
I would advise to read this:
http://symfony.com/doc/2.0/cookbook/security/custom_provider.html