|
@@ -46,11 +46,17 @@ use Macaroons\Verifier;
|
46
|
46
|
*/
|
47
|
47
|
class auth_plugin_macaroons extends auth_plugin_base {
|
48
|
48
|
|
|
49
|
+ /*
|
|
50
|
+ * The name of the component. Used by the configuration.
|
|
51
|
+ */
|
|
52
|
+ const COMPONENT_NAME = 'auth_macaroons';
|
|
53
|
+
|
49
|
54
|
/**
|
50
|
55
|
* Constructor.
|
51
|
56
|
*/
|
52
|
57
|
public function __construct() {
|
53
|
58
|
$this->authtype = 'macaroons';
|
|
59
|
+ $this->config = get_config(self::COMPONENT_NAME);
|
54
|
60
|
}
|
55
|
61
|
|
56
|
62
|
/**
|
|
@@ -65,7 +71,8 @@ class auth_plugin_macaroons extends auth_plugin_base {
|
65
|
71
|
|
66
|
72
|
function loginpage_hook() {
|
67
|
73
|
global $DB, $login, $CFG;
|
68
|
|
- $message = "";
|
|
74
|
+ $placeholders[0] = "/{{firstname}}/";
|
|
75
|
+ $placeholders[1] = "/{{lastname}}/";
|
69
|
76
|
if(!empty($_COOKIE['das-macaroon'])) {
|
70
|
77
|
try {
|
71
|
78
|
$m = Macaroon::deserialize($_COOKIE['das-macaroon']);
|
|
@@ -84,8 +91,9 @@ class auth_plugin_macaroons extends auth_plugin_base {
|
84
|
91
|
if($user) {
|
85
|
92
|
$user->firstname = $name[0];
|
86
|
93
|
$user->lastname = $name[1];
|
87
|
|
- $user->email = $login."@brendanabolivier.com";
|
|
94
|
+ $user->email = preg_replace($placeholders, $name, $this->config->email_config);
|
88
|
95
|
$DB->update_record('user', $user);
|
|
96
|
+
|
89
|
97
|
complete_user_login($user);
|
90
|
98
|
redirect($CFG->wwwroot);
|
91
|
99
|
}
|
|
@@ -188,15 +196,20 @@ class auth_plugin_macaroons extends auth_plugin_base {
|
188
|
196
|
* a form for configuring this plugin.
|
189
|
197
|
*
|
190
|
198
|
* @param array $page An object containing all the data for this page.
|
|
199
|
+ */
|
191
|
200
|
function config_form($config, $err, $user_fields) {
|
192
|
201
|
include "config.html";
|
193
|
202
|
}
|
194
|
|
- */
|
195
|
203
|
|
196
|
204
|
/**
|
197
|
205
|
* Processes and stores configuration data for this authentication plugin.
|
198
|
206
|
*/
|
199
|
207
|
function process_config($config) {
|
|
208
|
+ if(!isset($config->email_config)) {
|
|
209
|
+ $config->email_config = '';
|
|
210
|
+ }
|
|
211
|
+
|
|
212
|
+ set_config('email_config', $config->email_config, self::COMPONENT_NAME);
|
200
|
213
|
return true;
|
201
|
214
|
}
|
202
|
215
|
|