Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DP-499 Integrateio sso #102

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddIntegrateioIdFieldToUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasColumn('user', 'integrateio_id')) {
Schema::table(
'user',
function (Blueprint $t){
$t->integer('integrateio_id')->after('id')->nullable();
}
);
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
if (Schema::hasColumn('user', 'integrateio_id')) {
Schema::table(
'user',
function (Blueprint $t){
$t->dropColumn('integrateio_id');
}
);
}
}
}
2 changes: 1 addition & 1 deletion src/Components/RestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use DreamFactory\Core\Exceptions\NotFoundException;
use DreamFactory\Core\Utility\ResourcesWrapper;
use DreamFactory\Core\Utility\ResponseFactory;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Illuminate\Http\RedirectResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Controllers/RestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
use DreamFactory\Core\Utility\Session;
use Log;
use ServiceManager;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\RedirectResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class User extends BaseSystemModel implements AuthenticatableContract, CanResetP
'oauth_provider',
'last_login_date',
'default_app_id',
'saml'
'saml',
'integrateio_id'
];

/**
Expand All @@ -110,7 +111,7 @@ class User extends BaseSystemModel implements AuthenticatableContract, CanResetP
*
* @var array
*/
protected $hidden = ['is_sys_admin', 'password', 'remember_token', 'security_answer'];
protected $hidden = ['is_sys_admin', 'password', 'remember_token', 'security_answer', 'confirm_code'];

/**
* Field type casting
Expand Down
19 changes: 19 additions & 0 deletions src/Utility/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,25 @@ public static function replaceLookups(&$subject, $use_private = false)
*/
public static function authenticate(array $credentials, $remember = false, $login = true, $appId = null)
{

if (isset($credentials['integrateio_id'])) {
$userid = User::where('integrateio_id', $credentials['integrateio_id']) -> first() ->id;
$user = \Auth::loginUsingId($userid);
static::checkRole($user->id);
if ($login) {
tomonorman marked this conversation as resolved.
Show resolved Hide resolved
/** @noinspection PhpUndefinedFieldInspection */
$user->last_login_date = Carbon::now()->toDateTimeString();
/** @noinspection PhpUndefinedFieldInspection */
$user->confirm_code = 'y';
/** @noinspection PhpUndefinedMethodInspection */
$user->save();
/** @noinspection PhpParamsInspection */
Session::setUserInfoWithJWT($user, $remember, $appId);
}

return true;
}

tomonorman marked this conversation as resolved.
Show resolved Hide resolved
if (\Auth::attempt($credentials)) {
$user = \Auth::getLastAttempted();
/** @noinspection PhpUndefinedFieldInspection */
Expand Down