浏览代码

Simplified user_login, moved loginpage_hook

父节点
当前提交
28f92b39f1
共有 1 个文件被更改,包括 14 次插入19 次删除
  1. 14
    19
      auth.php

+ 14
- 19
auth.php 查看文件

53
 		$this->authtype = 'macaroons';
53
 		$this->authtype = 'macaroons';
54
 	}
54
 	}
55
 
55
 
56
+	/**
57
+	 * Old syntax of class constructor. Deprecated in PHP7.
58
+	 *
59
+	 * @deprecated since Moodle 3.1
60
+	 */
61
+	public function auth_plugin_macaroons() {
62
+		debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
63
+		self::__construct();
64
+	}
65
+
56
 	function loginpage_hook() {
66
 	function loginpage_hook() {
57
-		global $message, $DB;
67
+		global $DB;
58
 		$message = "";
68
 		$message = "";
59
 		if(!empty($_COOKIE['das-macaroon'])) {
69
 		if(!empty($_COOKIE['das-macaroon'])) {
60
 			try {
70
 			try {
65
 						return !strcmp($a, "status = student");
75
 						return !strcmp($a, "status = student");
66
 					}
76
 					}
67
 				]);
77
 				]);
78
+
68
 				if($v->verify($m, "pocsecret")) {
79
 				if($v->verify($m, "pocsecret")) {
69
 					$name = explode(";", $m->getIdentifier());
80
 					$name = explode(";", $m->getIdentifier());
70
 					$username = join("", $name);
81
 					$username = join("", $name);
71
 					$user = authenticate_user_login($username, null);
82
 					$user = authenticate_user_login($username, null);
72
 
83
 
73
-
74
 					if($user) {
84
 					if($user) {
75
 						$user->firstname = $name[0];
85
 						$user->firstname = $name[0];
76
 						$user->lastname = $name[1];
86
 						$user->lastname = $name[1];
77
 						$user->email = $username."@brendanabolivier.com";
87
 						$user->email = $username."@brendanabolivier.com";
78
-//						var_dump($user);
88
+						//	var_dump($user);
79
 						$DB->update_record('user', $user);
89
 						$DB->update_record('user', $user);
80
 						complete_user_login($user);
90
 						complete_user_login($user);
81
 					}
91
 					}
87
 	}
97
 	}
88
 
98
 
89
 	/**
99
 	/**
90
-	 * Old syntax of class constructor. Deprecated in PHP7.
91
-	 *
92
-	 * @deprecated since Moodle 3.1
93
-	 */
94
-	public function auth_plugin_macaroons() {
95
-		debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
96
-		self::__construct();
97
-	}
98
-
99
-	/**
100
 	 * Returns true if the username and password work or don't exist and false
100
 	 * Returns true if the username and password work or don't exist and false
101
 	 * if the user exists and the password is wrong.
101
 	 * if the user exists and the password is wrong.
102
 	 *
102
 	 *
105
 	 * @return bool Authentication success or failure.
105
 	 * @return bool Authentication success or failure.
106
 	 */
106
 	 */
107
 	function user_login ($username, $password) {
107
 	function user_login ($username, $password) {
108
-		global $message;
109
-		if(!empty($message)) {
110
-			return false;
111
-		} elseif(!empty($_COOKIE['das-macaroon'])) {
112
-			return true;
113
-		}
108
+		return true;
114
 	}
109
 	}
115
 
110
 
116
 	/**
111
 	/**