Retrieving session in another domain using nuxtjs and laravel sanctum - nuxtjs

Good morning!
Here is the problem i'm facing: (i'm using NuxtJs and Laravel Sanctum)
I have a domain : 'testingdomain.com'
And with this main domain i have subdomains such as :
myfirstdomain.testingdomain.com
myotherdomain.testingdomain.com
connexion.testingdomain.com
my application work this way: i have the connexion.testingdomain.com that help my users getting redirected to the corresponding url for example:
A user 'john.doe#gmail.com' is registered in a company that use the url 'myotherdomain.testingdomain.com' so whenever he write his mail in the input displayed in connexion.testingdomain.com, he will be redirect to the corresponding url which for this example is -> 'myotherdomain.testingdomain.com'.
However if the user is logged in 'myotherdomain.testingdomain.com' and re-enter the 'connexion.testingdomain.com' i would like him to be redirected to the subdomain where he is authentified but i do not know how to achieve this because i can't access the $auth state from the 'myotherdomain.testingdomain.com' (he is logged so this.$auth.loggedIn is true) in 'connexion.testingdomain.com' (this.$auth.loggedIn is set to false)
Has anyone faced a similar problem and could help me ?
Thanks

Related

How to get redirect the given, correct and clean URL after Facebook authentication in Laravel?

I am developing a functionality to allow facebook users to register in our web application. The approach is:
We will create one app on facebook
Facebook authentication plugin (http://developers.facebook.com/docs/guides/web/#login) will be used in our registration page.
When user clicks on facebook button, facebook login page and then app authorization page are shown.
One user allows/disallows facebook app, user will be redirected to the main page(https://example.com)
But it's redirected like this(https://example.com/#=), so I am facing another issue with that.
Appended this characters(#=)
I have tried to fix the url, but it's redirected like that anyway.
Here is the redirection code.
Auth::login($user);
return Redirect::to(URL('/'));
My server is Nginx.
Hope to get solved my problem.
Thanks in advance!
Try to name the route then redirect to it.
Route::get('/', 'HomeController#index')-
>name('home');
then redirect()->to(route('home'));

Laravel passport Oauth2 "Requesting Tokens"

I am working with Zapier, and trying to authenticate user using OAuth2. I am using the Laravel(5.5) Passport(^4.0).
I am trying to use defalut passport routes "https://laravel.com/docs/5.5/passport".
But when it goes to "oauth/authorize" GET method and if user is not logged in then gives me {"error":"Unauthenticated."} instead of redirecting to Login page. And if user is logged in already then worked well.
Is there something i am missing and where I can check to resolve this issue.
Thanks and Regards
You are working with Oauth2 so you will get 401 and {"error" : "Unauthenticated"}. It is up to you to handle the unauthenticated response to the server (e.g. your js front end will redirect or your mobile app show login page).

Laravel Client Credentials Check in api.php

So I'm creating a laravel app where part of the front end lives on a cold fusion site and the people interacting with my API are not "users", just people signing up for seminars/consultations. My question is I've been able to grant tokens using the grant_type client credentials and in the web.php file with ->middleware('client') attached to the route (or a route group for multiple routes) it works just fine. However I've been told to move them into my api.php file and everything. I cannot seem to get it to work. In postman all I get for a response is to be brought back to the login page because I am not a logged in user. Any ideas?
in api file every middleware that wants to check credential use authorizing it means you should use laravel passport for

redirect()->intended('/login') not working laravel

I'm using a custom SocialLoginController to log my users with facebook or google in al Laravel 5.3 project
In some cases I send to users an email with info about one change and the URL to the resource, for example https://myweb.com/settings/profile/[the-uuid]
when the user tries to access but is not logged in, he's redirected to the Handler#render() where I send it to login with return redirect()->guest('/login'); and after login with social account I redirect them using return redirect()->intended('/home') but since I don't use the LoginController, the redirection to the requested URL is not working.
Any idea? Thanks
The problem is the request object is lost after redirect the user to login with facebook or google, so I fixed by saving the requested URI in a session variable and then checking if exists after redirect
return Session::get('intended') ? redirect()->to(\Session::get('intended')) : redirect()->to('/expenses');
Maybe this could help someone

Cross Domain session in laravel

I need to share session values between domain A and domain B.
I am trying to login to domain B,the code for login and signup are written in domain A. Once logged in the user will be redirected to domain B.The problem i am facing is that i am unable to fetch the unique id of logged in user which is stored in session. Call to login function is made via an API.I am able to store and fetch the session value on the same page. But when i try to fetch the session value in different page, its showing null.
Note: domain B is not a subdomain. They are two different domains.
Can anyone help me in solving this issue?

Resources