<excludeFolder url="file://$MODULE_DIR$/vendor/psr/event-dispatcher" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/http-client" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/container" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/spatie/laravel-permission" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
"php": ">=7.3.0",
"laravel/framework": "~5.8|^6.0|^7.0|^8.0",
"laravel/socialite": "^v5.2.5",
- "socialiteproviders/google": "^4.1.0"
+ "socialiteproviders/google": "^4.1.0",
+ "spatie/laravel-permission": "^5.1"
},
"repositories": [
{
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "916d7e90dfa6ee9e0626bd40cfe06971",
+ "content-hash": "8b8015300b432692677e4ad1b680c0e0",
"packages": [
{
"name": "brick/math",
},
"time": "2020-12-01T23:09:06+00:00"
},
+ {
+ "name": "spatie/laravel-permission",
+ "version": "5.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/spatie/laravel-permission.git",
+ "reference": "58d5eb6c7b0eafa8bdf0a93d1ca5c214a05344cb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/spatie/laravel-permission/zipball/58d5eb6c7b0eafa8bdf0a93d1ca5c214a05344cb",
+ "reference": "58d5eb6c7b0eafa8bdf0a93d1ca5c214a05344cb",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/auth": "^6.0|^7.0|^8.0",
+ "illuminate/container": "^6.0|^7.0|^8.0",
+ "illuminate/contracts": "^6.0|^7.0|^8.0",
+ "illuminate/database": "^6.0|^7.0|^8.0",
+ "php": "^7.2.5|^8.0"
+ },
+ "require-dev": {
+ "orchestra/testbench": "^4.0|^5.0|^6.0",
+ "phpunit/phpunit": "^8.0|^9.0",
+ "predis/predis": "^1.1"
+ },
+ "type": "library",
+ "extra": {
+ "laravel": {
+ "providers": [
+ "Spatie\\Permission\\PermissionServiceProvider"
+ ]
+ },
+ "branch-alias": {
+ "dev-main": "5.x-dev",
+ "dev-master": "5.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Spatie\\Permission\\": "src"
+ },
+ "files": [
+ "src/helpers.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Freek Van der Herten",
+ "email": "freek@spatie.be",
+ "homepage": "https://spatie.be",
+ "role": "Developer"
+ }
+ ],
+ "description": "Permission handling for Laravel 6.0 and up",
+ "homepage": "https://github.com/spatie/laravel-permission",
+ "keywords": [
+ "acl",
+ "laravel",
+ "permission",
+ "permissions",
+ "rbac",
+ "roles",
+ "security",
+ "spatie"
+ ],
+ "support": {
+ "issues": "https://github.com/spatie/laravel-permission/issues",
+ "source": "https://github.com/spatie/laravel-permission/tree/5.1.1"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/spatie",
+ "type": "github"
+ }
+ ],
+ "time": "2021-09-01T20:02:17+00:00"
+ },
{
"name": "swiftmailer/swiftmailer",
"version": "v6.2.7",
namespace Cubist\Socialite\Http\Controllers;
use Cubist\Socialite\CubistSocialiteServiceProvider;
+use Cubist\Socialite\User;
use Illuminate\Routing\Controller;
+use Illuminate\Support\Facades\Auth;
use Laravel\Socialite\Facades\Socialite;
class SocialiteController extends Controller
{
$provider = request()->provider;
if (in_array($provider, $this->providers)) {
- $data = Socialite::driver($provider)->user();
- $user = $data->user;
- dd($user);
+ $socialiteUser=Socialite::driver($provider)->user();
+ if($socialiteUser) {
+ Auth::login(new User($socialiteUser),true);
+ }
}
abort(403);
}
--- /dev/null
+<?php
+
+namespace Cubist\Socialite;
+
+use Illuminate\Auth\Authenticatable;
+use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
+use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
+use Illuminate\Foundation\Auth\Access\Authorizable;
+use Illuminate\Notifications\Notifiable;
+use Spatie\Permission\Traits\HasRoles;
+
+class User implements
+ AuthenticatableContract,
+ AuthorizableContract
+{
+ use Authenticatable, Authorizable;
+ use Notifiable;
+ use HasRoles;
+
+ protected $provider;
+
+ protected $name;
+ protected $email;
+ protected $avatar;
+ protected $id;
+ protected $nickname;
+
+ /**
+ * @var \Laravel\Socialite\Contracts\User
+ */
+ protected $socialiteUser;
+
+ public function __construct($socialiteUser)
+ {
+ $this->socialiteUser=$socialiteUser;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getName()
+ {
+ return $this->socialiteUser->getName();
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getAvatar()
+ {
+ return $this->socialiteUser->getAvatar();
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getEmail()
+ {
+ return $this->socialiteUser->getEmail();
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getNickname()
+ {
+ return $this->socialiteUser->getNickname();
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getId()
+ {
+ return $this->socialiteUser->getId();
+ }
+
+}
\ No newline at end of file