2017 © Pedro Peláez
 

package mobileid

Estonian MobileID identity provider for laravel

image

kullar84/mobileid

Estonian MobileID identity provider for laravel

  • Tuesday, January 16, 2018
  • by kullar84
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

MobileID

Laravel mobile ID authentication, (*1)

Installation

composer require kullar84/mobileid

The package is now installed. If you are using laravel version < 5.5, add the following line in your config/app.php providers section:, (*2)

kullar84\mobileid\MobileIDServiceProvider::class,

Create new middleware group to Kernel.php, (*3)

protected $middlewareGroups = [
        'session' => [
            \Illuminate\Session\Middleware\StartSession::class,
        ],
    ];

Add new routes that uses this middleware, (*4)

Route::group(['middleware' => 'session'], function () {
    Route::post('mlogin', 'AuthController@mlogin')->name('mlogin');
    Route::post('domlogin', 'AuthController@doMLogin')->name('domlogin');
});

Create required methods, (*5)

use kullar84\mobileid\MobileIDAuthenticate;


protected function mlogin(Request $request)
{
    $this->validate(
        $request, [
            'phone' => 'required|numeric|exists:users,phone',
        ]
    );

    $phone = $request->input('phone');

    $auth = new MobileIDAuthenticate();

    $response = $auth->startAuth($phone);

    return response()->json($response);
}

protected function doMLogin(Request $request)
{
    //https://www.id.ee/?id=36373
    $auth = new MobileIDAuthenticate();
    $response = $auth->checkAuthStatus();

    if ($response->isError()) {
        return response()->json(['error' => true, 'message' => $response->error]);
    } elseif ($response->isPending()) {
        return response()->json(['pending' => true, 'message' => 'Please wait! You will be redirected shortly']);
    } elseif ($response->isSuccess()) {
        $phone = $request->input('phone');

        $user = User::findUserByPhone($phone);

        if ($user !== null) {
            $token = $user->createToken('Token')->accessToken;

            return $this->respondWithToken($token);
        }
    }

    return response()->json(['message' => 'Unauthorized'], 422);
}

The Versions

16/01 2018

dev-master

9999999-dev

Estonian MobileID identity provider for laravel

  Sources   Download

MIT

The Requires

 

laravel auth identity mobiilid digidocservice mobileid

16/01 2018

0.2

0.2.0.0

Estonian MobileID identity provider for laravel

  Sources   Download

MIT

The Requires

 

laravel auth identity mobiilid digidocservice mobileid

16/01 2018

0.1

0.1.0.0

Estonian MobileID identity provider

  Sources   Download

MIT

The Requires

 

laravel auth identity mobiilid digidocservice mobileid