Skip to content

Commit

Permalink
Changed namsespace
Browse files Browse the repository at this point in the history
  • Loading branch information
kullarkert committed Jan 16, 2018
1 parent 29c46e3 commit 93f4fa2
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 10 deletions.
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,78 @@
# MobileID
Laravel mobile ID authentication

## 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:
```
kullar84\mobileid\MobileIDServiceProvider::class,
```

Create new middleware group to Kernel.php
```
protected $middlewareGroups = [
'session' => [
\Illuminate\Session\Middleware\StartSession::class,
],
];
```

Add new routes that uses this middleware
```
Route::group(['middleware' => 'session'], function () {
Route::post('mlogin', 'AuthController@mlogin')->name('mlogin');
Route::post('domlogin', 'AuthController@doMLogin')->name('domlogin');
});
```

Create required methods
```
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);
}
```
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "kullar84/mobile-id",
"name": "kullar84/mobileid",
"description": "Estonian MobileID identity provider for laravel",
"keywords": ["MobileID", "identity", "auth", "digidocservice","MobiilID","laravel"],
"type": "package",
Expand All @@ -17,16 +17,16 @@
},
"autoload": {
"psr-4": {
"kullar84\\MobileID\\": "src/"
"kullar84\\mobileid\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"kullar84\\MobileID\\MobileIDServiceProvider"
"kullar84\\mobileid\\MobileIDServiceProvider"
],
"aliases": {
"MobileID": "kullar84\\MobileID\\MobileIDFacade"
"MobileID": "kullar84\\mobileid\\MobileIDFacade"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/AuthenticateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @license https://opensource.org/licenses/MIT MIT
*/

namespace kullar84\MobileID;
namespace kullar84\mobileid;

/**
* Mobile ID authentication response
Expand Down
2 changes: 1 addition & 1 deletion src/MobileIDAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/


namespace kullar84\MobileID;
namespace kullar84\mobileid;

use Session;

Expand Down
2 changes: 1 addition & 1 deletion src/MobileIDException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @license https://opensource.org/licenses/MIT MIT
*/

namespace kullar84\MobileID;
namespace kullar84\mobileid;

use Exception;

Expand Down
4 changes: 2 additions & 2 deletions src/MobileIDFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @license https://opensource.org/licenses/MIT MIT
*/

namespace kullar84\MobileID;
namespace kullar84\mobileid;

use \Illuminate\Support\Facades\Facade;

Expand All @@ -25,6 +25,6 @@ class MobileIDFacade extends Facade
*/
protected static function getFacadeAccessor()
{
return 'MobileID';
return 'mobileid';
}
}
2 changes: 1 addition & 1 deletion src/MobileIDServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @license https://opensource.org/licenses/MIT MIT
*/

namespace kullar84\MobileID;
namespace kullar84\mobileid;

use Illuminate\Support\ServiceProvider;

Expand Down

0 comments on commit 93f4fa2

Please sign in to comment.