s4uron

Experience

300

0 Best Reply Awards

  • Member Since 6 Months Ago
  • 1 Lesson Completed
  • 0 Favorites

6th July, 2017

s4uron left a reply on @gmail.com & @googlemail.com Login • 4 months ago

@Snapey well that's a good idea. Maybe I stop searching for an existing email, instead i search for a matching google_uid to identify the user :) So best practice may be to add a social_login table for every account containing that google id :)

5th July, 2017

s4uron left a reply on @gmail.com & @googlemail.com Login • 4 months ago

To combine [email protected] and [email protected] :S Someone logging in via Google+ shouldn't have 2 accounts using sometimes [email protected] and other times [email protected]

4th July, 2017

s4uron started a new conversation @gmail.com & @googlemail.com Login • 4 months ago

Hey guys,

i have trouble with the social login (google+) because a user logging in with his gmail-adress can create 2 accounts. One with the gmail.com ending and one with googlemail.com.

How to make it possible that a login with googlemail.com will be a gmail.com login?

Regards

8th June, 2017

s4uron left a reply on User Session Organization & Auhtorization • 5 months ago

I created a new middleware:

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;

class CheckSession
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @param null $guard
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = null)
    {
        if(Auth::guard($guard)->check() && !empty(session('confirmation'))) {
            return new Response('This session is not unlocked yet! <a href="'.route('auth.confirm',session('confirmation')).'">Unlock</a>',402);
        }
        return $next($request);
    }
}

a custom SessionHandler

<?php

namespace App\Extensions;


use Illuminate\Session\DatabaseSessionHandler;

class CustomSessionHandler extends DatabaseSessionHandler
{

    /**
     * {@inheritdoc}
     */
    public function read($sessionId)
    {
        $session = (object) $this->getQuery()->find($sessionId);

        if ($this->expired($session)) {
            $this->exists = true;

            return;
        }

        if (isset($session->payload)) {
            $this->exists = true;
            $s = unserialize(base64_decode($session->payload));
            $s['confirmation'] = $session->confirmation;
            return serialize($s);
        }
    }

}

added

$table->string('confirmation')->default('');

to the session migration, registered the custom session handler in my appServiceProvider

<?php

namespace App\Providers;

use App\Extensions\CustomSessionHandler;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Session::extend('mySession', function($app) {
            $table = $app['config']['session.table'];
            $lifetime = $app['config']['session.lifetime'];
            $connection = $app['config']['session.connection'];
            return new CustomSessionHandler($app['db']->connection($connection), $table, $lifetime, $app);
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

and used it in session.php / .env and added a route to confirm with the token.

But now I have the question whats the best way to create a random conrimation code when a user loggs in?

7th June, 2017

s4uron started a new conversation User Session Organization & Auhtorization • 5 months ago

Hey guys,

I want to implement the following: A user loggs in -> an email with a unlock link is sent to the assigned email -> if clicked on the link the login / session will be unlocked (Until that a massage is shown that this session is not unlocked yet) If the user successfully loggs in, he can view all sessions and the locking status and may delte/revoke them

To sum up, I want to implement a session organization where a user can see all connected devices (like for example google has). But I have no idea how to accomplish.

Thanks for any ideas :)

Could the session locking status be checked by a custom middleware? In order to organize the session should I change the session driver to database?

18th May, 2017

s4uron left a reply on Policy Methods Automatically Calling • 6 months ago

@martinbean Thanks a lot I will give it a try.

whats about index?

@thepassenger That would be an extra afford because I'm using Route::resource(..)

s4uron left a reply on Policy Methods Automatically Calling • 6 months ago

push

16th May, 2017

s4uron started a new conversation Policy Methods Automatically Calling • 6 months ago

It would be great if the policy methods get called automatically if they match the method name in the controller.

For example if I have the function public function create() {.....} in my Controller i want the matching Policy public function create(User $user) {...} automatically to be called without writing $this->authorize('create'); in every single method in my controller.

Regards s4uron

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.