Brendan Abolivier 7 år sedan
förälder
incheckning
429555b62d
1 ändrade filer med 14 tillägg och 8 borttagningar
  1. 14
    8
      auth.php

+ 14
- 8
auth.php Visa fil

@@ -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