#1019 Add email field to web integration sample

This commit is contained in:
ljacqu
2017-01-22 11:17:31 +01:00
parent cc7deb64c8
commit aa64f96466
2 changed files with 19 additions and 7 deletions
@@ -54,16 +54,18 @@ abstract class AuthMeController {
*
* @param string $username the username to register
* @param string $password the password to associate to the user
* @param string $email the email (may be empty)
* @return bool whether or not the registration was successful
*/
function register($username, $password) {
function register($username, $password, $email) {
$email = $email ? $email : 'your@email.com';
$mysqli = $this->getAuthmeMySqli();
if ($mysqli !== null) {
$hash = $this->hash($password);
$stmt = $mysqli->prepare('INSERT INTO ' . self::AUTHME_TABLE . ' (username, realname, password, ip) '
. 'VALUES (?, ?, ?, ?)');
$stmt = $mysqli->prepare('INSERT INTO ' . self::AUTHME_TABLE . ' (username, realname, password, email, ip) '
. 'VALUES (?, ?, ?, ?, ?)');
$username_low = strtolower($username);
$stmt->bind_param('ssss', $username, $username_low, $hash, $_SERVER['REMOTE_ADDR']);
$stmt->bind_param('sssss', $username, $username_low, $hash, $email, $_SERVER['REMOTE_ADDR']);
return $stmt->execute();
}
return false;