Skip to content
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.

Modified to work with one table. Added "provider" field. Removed old mig... #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/Thomaswelton/LaravelOauth/Eloquent/Facebook.php

This file was deleted.

6 changes: 0 additions & 6 deletions src/Thomaswelton/LaravelOauth/Eloquent/Github.php

This file was deleted.

6 changes: 0 additions & 6 deletions src/Thomaswelton/LaravelOauth/Eloquent/Google.php

This file was deleted.

6 changes: 0 additions & 6 deletions src/Thomaswelton/LaravelOauth/Eloquent/Instagram.php

This file was deleted.

6 changes: 6 additions & 0 deletions src/Thomaswelton/LaravelOauth/Eloquent/Oauth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php namespace Thomaswelton\LaravelOauth\Eloquent;

class Oauth extends AbstractModel
{
protected $table = 'oauth';
}
6 changes: 0 additions & 6 deletions src/Thomaswelton/LaravelOauth/Eloquent/Twitter.php

This file was deleted.

8 changes: 4 additions & 4 deletions src/controllers/OAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public function index($provider)
if (property_exists($state, 'login')) {
$uid = $this->oauth->user($provider)->getUID();

$modelName = "Thomaswelton\\LaravelOauth\\Eloquent\\".ucfirst($provider);
$modelName = "Thomaswelton\\LaravelOauth\\Eloquent\\Oauth";
$model = new $modelName();

$user = $model->where('oauth_uid', '=', $uid)->firstOrFail();
$user = $model->where('oauth_uid', '=', $uid)->where('provider', '=', $provider)->firstOrFail();
Auth::loginUsingId($user->user_id);
}

Expand All @@ -49,14 +49,14 @@ public function index($provider)
if(is_object($user->$providerClass)){
$model = $user->$providerClass;
}else{
$modelName = "Thomaswelton\\LaravelOauth\\Eloquent\\".$providerClass;
$modelName = "Thomaswelton\\LaravelOauth\\Eloquent\\Oauth";
$model = new $modelName();
}

$model->oauth_uid = $uid;
$model->access_token = $token->getAccessToken();
$model->expire_time = $token->getEndOfLife();

$model->provider = $provider;
$user->$provider()->save($model);
}else{
throw new NotLoggedInException("NOT_LOGGED_IN", 1);
Expand Down
37 changes: 0 additions & 37 deletions src/migrations/2013_09_01_024008_migration_oauth_github.php

This file was deleted.

37 changes: 0 additions & 37 deletions src/migrations/2013_09_01_024008_migration_oauth_google.php

This file was deleted.

37 changes: 0 additions & 37 deletions src/migrations/2013_09_01_024008_migration_oauth_instagram.php

This file was deleted.

37 changes: 0 additions & 37 deletions src/migrations/2013_09_01_024008_migration_oauth_twitter.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Illuminate\Database\Migrations\Migration;

class MigrationOauthFacebook extends Migration {
class MigrationOauth extends Migration {

/**
* Run the migrations.
Expand All @@ -11,12 +11,13 @@ class MigrationOauthFacebook extends Migration {
*/
public function up()
{
Schema::create('oauth_facebook', function($table) {
Schema::create('oauth', function($table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->unique();
$table->text('oauth_uid');
$table->text('access_token');
$table->integer('expire_time');
$table->text('provider');

$table->timestamps();

Expand All @@ -31,7 +32,7 @@ public function up()
*/
public function down()
{
Schema::drop('oauth_facebook');
Schema::drop('oauth');
}

}