-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.php
55 lines (42 loc) · 1.09 KB
/
action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
use dokuwiki\plugin\oauth\Adapter;
use dokuwiki\plugin\oauthslack\Slack;
/**
* Service Implementation for oAuth Slack authentication
*/
class action_plugin_oauthslack extends Adapter
{
/** @inheritdoc */
public function registerServiceClass()
{
return Slack::class;
}
/** * @inheritDoc */
public function getUser()
{
$oauth = $this->getOAuthService();
$data = array();
$url = 'https://slack.com/api/openid.connect.userInfo';
$raw = $oauth->request($url);
$result = json_decode($raw, true);
$username = str_replace(' ', '_', strtolower($result['name']));
$data['user'] = $username;
$data['name'] = $result['given_name'] . ' ' . $result['family_name'];
$data['mail'] = $result['email'];
return $data;
}
public function getScopes()
{
return ['openid', 'email', 'profile'];
}
/** @inheritDoc */
public function getLabel()
{
return 'Slack';
}
/** @inheritDoc */
public function getColor()
{
return '#4A154B';
}
}