Skip to content
This repository was archived by the owner on Mar 13, 2020. It is now read-only.

Commit 08a7293

Browse files
authored
Merge pull request #21 from jasonjoh/refactor
Refactor
2 parents 13d17ba + 1231272 commit 08a7293

5 files changed

Lines changed: 3 additions & 10 deletions

File tree

‎.env.example‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ PUSHER_APP_SECRET=
3434
OAUTH_APP_ID=YOUR_APP_ID_HERE
3535
OAUTH_APP_PASSWORD=YOUR_APP_PASSWORD_HERE
3636
OAUTH_REDIRECT_URI=http://localhost:8000/authorize
37-
OAUTH_SCOPES='openid profile offline_access User.Read Mail.Read'
37+
OAUTH_SCOPES='openid profile offline_access User.Read Mail.Read Calendars.Read Contacts.Read'
3838
OAUTH_AUTHORITY=https://login.microsoftonline.com/common
3939
OAUTH_AUTHORIZE_ENDPOINT=/oauth2/v2.0/authorize
4040
OAUTH_TOKEN_ENDPOINT=/oauth2/v2.0/token

‎app/Http/Controllers/AuthController.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public function signin()
2727
$authorizationUrl = $oauthClient->getAuthorizationUrl();
2828

2929
// Save client state so we can validate in response
30-
\Log::info('State for auth request: '.$oauthClient->getState());
3130
$_SESSION['oauth_state'] = $oauthClient->getState();
3231

3332
// Redirect to authorization endpoint

‎app/Http/Controllers/OutlookController.php‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ public function mail()
3434

3535
$getMessagesUrl = '/me/mailfolders/inbox/messages?'.http_build_query($messageQueryParams);
3636
$messages = $graph->createRequest('GET', $getMessagesUrl)
37-
->addHeaders(array ('X-AnchorMailbox' => $user->getMail()))
3837
->setReturnType(Model\Message::class)
3938
->execute();
4039

4140
return view('mail', array(
4241
'username' => $user->getDisplayName(),
43-
'usermail' => $user->getMail(),
4442
'messages' => $messages
4543
));
4644
}
@@ -71,13 +69,11 @@ public function calendar()
7169

7270
$getEventsUrl = '/me/events?'.http_build_query($eventsQueryParams);
7371
$events = $graph->createRequest('GET', $getEventsUrl)
74-
->addHeaders(array ('X-AnchorMailbox' => $user->getMail()))
7572
->setReturnType(Model\Event::class)
7673
->execute();
7774

7875
return view('calendar', array(
7976
'username' => $user->getDisplayName(),
80-
'usermail' => $user->getMail(),
8177
'events' => $events
8278
));
8379
}
@@ -108,13 +104,11 @@ public function contacts()
108104

109105
$getContactsUrl = '/me/contacts?'.http_build_query($contactsQueryParams);
110106
$contacts = $graph->createRequest('GET', $getContactsUrl)
111-
->addHeaders(array ('X-AnchorMailbox' => $user->getMail()))
112107
->setReturnType(Model\Contact::class)
113108
->execute();
114109

115110
return view('contacts', array(
116111
'username' => $user->getDisplayName(),
117-
'usermail' => $user->getMail(),
118112
'contacts' => $contacts
119113
));
120114
}

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"laravel/framework": "5.4.*",
1010
"laravel/tinker": "~1.0",
1111
"league/oauth2-client": "^2.0",
12-
"microsoft/microsoft-graph": "1.0.*"
12+
"microsoft/microsoft-graph": "^1.0"
1313
},
1414
"require-dev": {
1515
"fzaninotto/faker": "~1.4",

‎resources/views/contacts.blade.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
foreach($contacts as $contact) { ?>
1414
<div class="list-group-item">
1515
<h3 class="list-group-item-heading"><?php echo $contact->getGivenName().' '.$contact->getSurname() ?></h3>
16-
<p class="list-group-item-heading"><?php echo $contact->getEmailAddresses()[0]['address']?></p>
16+
<p class="list-group-item-heading"><?php if ($contact->getEmailAddresses()) echo $contact->getEmailAddresses()[0]['address']?></p>
1717
</div>
1818
<?php }
1919
} ?>

0 commit comments

Comments
 (0)