Skip to content

Commit 36c555c

Browse files
committed
fix authenticate method
1 parent 010f6db commit 36c555c

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# php-mattermost-driver (v3.7.0)
22

3-
Completed Php Driver to interact with the [Mattermost Web Service API][4].
3+
Completed Php Driver to interact with the [Mattermost Web Service API][4].
4+
Version of the Mattermost server required: 3.7.0
45

5-
Version of the Mattermost server required: 3.7.0
66
Please read [the api documentation][1] for further information on using this application.
77

88
## Installation
@@ -31,13 +31,7 @@ Read more about how to install and use Composer on your local machine [here][3].
3131
]);
3232

3333
$driver = new Driver($container);
34-
$login = $driver->authenticate();
35-
36-
if ($login) {
37-
echo "SUCCESS!";
38-
} else {
39-
echo "SOMETHING WENT WRONG.";
40-
}
34+
$result = $driver->authenticate();
4135
```
4236

4337
### Check results
@@ -63,7 +57,7 @@ $requestOptions = [
6357
$result = $driver->getUserModel()->createUser($requestOptions);
6458

6559
//Get a user
66-
$res = $driver->getUserModel()->getUserByUsername('username');
60+
$result = $driver->getUserModel()->getUserByUsername('username');
6761
```
6862

6963
### Team data model
@@ -83,4 +77,4 @@ In Development, coming soon!
8377
[1]: https://api.mattermost.com/
8478
[2]: http://www.php-fig.org/psr/psr-7/
8579
[3]: https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
86-
[4]: https://about.mattermost.com/
80+
[4]: https://about.mattermost.com/

src/Driver.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(Container $container)
6262
}
6363

6464
/**
65-
* @return bool
65+
* @return null|\Psr\Http\Message\ResponseInterface
6666
*/
6767
public function authenticate()
6868
{
@@ -75,16 +75,13 @@ public function authenticate()
7575
/** @var Client $client */
7676
$client = $this->container['client'];
7777
$response = $client->post('/users/login', $options);
78-
$statusCode = $response->getStatusCode();
7978

80-
if ($statusCode == 200) {
79+
if ($response->getStatusCode() == 200) {
8180
$token = $response->getHeader('Token')[0];
8281
$client->setToken($token);
83-
84-
return true;
8582
}
8683

87-
return false;
84+
return $response;
8885
}
8986

9087
/**

0 commit comments

Comments
 (0)