Browse Source

Fixed stuff

Brendan Abolivier 8 years ago
parent
commit
429555b62d
1 changed files with 14 additions and 8 deletions
  1. 14
    8
      auth.php

+ 14
- 8
auth.php View File

54
 	}
54
 	}
55
 
55
 
56
 	function loginpage_hook() {
56
 	function loginpage_hook() {
57
-		global $message;
57
+		global $message, $DB;
58
 		$message = "";
58
 		$message = "";
59
 		if(!empty($_COOKIE['das-macaroon'])) {
59
 		if(!empty($_COOKIE['das-macaroon'])) {
60
 			try {
60
 			try {
61
 				$m = Macaroon::deserialize($_COOKIE['das-macaroon']);
61
 				$m = Macaroon::deserialize($_COOKIE['das-macaroon']);
62
-				$frm = new stdClass();
63
-				$frm->username = $m->getIdentifier();
64
-				$frm->password = 'passwdMacaroons';
65
 				$v = new Verifier();
62
 				$v = new Verifier();
66
 				$v->setCallbacks([
63
 				$v->setCallbacks([
67
 					function($a) {
64
 					function($a) {
69
 					}
66
 					}
70
 				]);
67
 				]);
71
 				if($v->verify($m, "pocsecret")) {
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
 			} catch(Exception $e) {
83
 			} catch(Exception $e) {
77
 				$message = $e->getMessage();
84
 				$message = $e->getMessage();
78
 			}
85
 			}
79
-			authenticate_user_login($frm->username, sesskey());
80
 		}
86
 		}
81
 	}
87
 	}
82
 
88