Skip to content

Commit 935f03a

Browse files
committed
Added code sample
1 parent 73780b8 commit 935f03a

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"keywords": [
66
"openid",
77
"authentication",
8-
"security"
8+
"security",
9+
"laravel",
10+
"scouting",
11+
"scoutingnederland"
912
],
1013
"homepage": "https://github.com/ScoutingRudyardKipling/SOLAuthenticator",
1114
"license": "MIT",

readme.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,37 @@ Deze package is met composer toe te voegen middels het volgende commando:
66

77
```bash
88
composer require scoutingrudyardkipling/solopenidclient
9+
```
10+
11+
### Voorbeeld (Laravel 5.x)
12+
13+
```php
14+
public function login(Illuminate\Http\Request $request)
15+
{
16+
$openid = new \ScoutingRudyardKipling\SOLOpenIdClient('http://your-return-url.nl');
17+
18+
if (!$openid->mode && $request->has('username')) {
19+
$username = $request->input('username');
20+
21+
return \Redirect::to($openid->setUserIdentity($username)->authUrl());
22+
} elseif (!!$openid->mode) {
23+
if ($openid->mode == 'cancel') {
24+
// user cancelled logging in
25+
} elseif ($openid->validate()) {
26+
// user login confirmed by Scouting Nederland, let's proceed!
27+
28+
$user = $openid->getValidatedUser();
29+
30+
// Either create a new user or link the returned SNL-user to one of your registered users.
31+
// Notice that SNL only confirmed that the user is who it claims to be and that he/she is an active
32+
// member of Scouting Nederland. You have to deal with authorisation yourself for instance to make sure
33+
// the authenticated user is a member of your scouting club.
34+
35+
} else {
36+
// login failed
37+
}
38+
} else {
39+
// show a form where the user can provide his/her SNL username
40+
}
41+
}
942
```

src/SOLOpenIdClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SOLOpenIdClient extends \LightOpenID
2828
private static $snl_login_namespace = 'https://login.scouting.nl/user/';
2929

3030
/**
31-
* Set the theme of the login page theme
31+
* Set the theme of the login page
3232
*
3333
* @param string $theme
3434
*/

0 commit comments

Comments
 (0)