瀏覽代碼

Fixed stuff

Brendan Abolivier 7 年之前
父節點
當前提交
429555b62d
共有 1 個檔案被更改,包括 14 行新增8 行删除
  1. 14
    8
      auth.php

+ 14
- 8
auth.php 查看文件

@@ -54,14 +54,11 @@ class auth_plugin_macaroons extends auth_plugin_base {
54 54
 	}
55 55
 
56 56
 	function loginpage_hook() {
57
-		global $message;
57
+		global $message, $DB;
58 58
 		$message = "";
59 59
 		if(!empty($_COOKIE['das-macaroon'])) {
60 60
 			try {
61 61
 				$m = Macaroon::deserialize($_COOKIE['das-macaroon']);
62
-				$frm = new stdClass();
63
-				$frm->username = $m->getIdentifier();
64
-				$frm->password = 'passwdMacaroons';
65 62
 				$v = new Verifier();
66 63
 				$v->setCallbacks([
67 64
 					function($a) {
@@ -69,14 +66,23 @@ class auth_plugin_macaroons extends auth_plugin_base {
69 66
 					}
70 67
 				]);
71 68
 				if($v->verify($m, "pocsecret")) {
72
-					$frm = new stdClass();
73
-					$frm->username = $m->getIdentifier();
74
-					$frm->password = 'passwdMacaroons';
69
+					$name = explode(";", $m->getIdentifier());
70
+					$username = join("", $name);
71
+					$user = authenticate_user_login($username, sesskey());
72
+
73
+
74
+					if($user) {
75
+						$user->firstname = $name[0];
76
+						$user->lastname = $name[1];
77
+						$user->email = $username."@brendanabolivier.com";
78
+//						var_dump($user);
79
+						$DB->update_record('user', $user);
80
+						complete_user_login($user);
81
+					}
75 82
 				}
76 83
 			} catch(Exception $e) {
77 84
 				$message = $e->getMessage();
78 85
 			}
79
-			authenticate_user_login($frm->username, sesskey());
80 86
 		}
81 87
 	}
82 88