Joriku
Working in the mines, need something?
This took me a headache and a rage ctrl + a - replace all name with email to figure out on a late night with no sleep. So if you're in the same boat, listen up.
For later canary projects or TFS projects that wants to use Email and Password instead of Username.
Let's start by changing your login.php, usually located in layout/sub
This is not really needed, however. This makes sure that an email starting with something @ ends with something . something has to be written. "Type=Email" that is.
Change:
To:
Now we enter engine/function/users.php
Find this:
Replace with:
Find:
Replace with:
Find:
Replace with:
This should be all you need to do in-order to change the method from using a username to logging in with an email address, I tried using an alternative login method. But it kept denying my request due to a token generated by default of Znote acc so this was a quick solution of my issue I came across.
Hope it helps.
For later canary projects or TFS projects that wants to use Email and Password instead of Username.
Let's start by changing your login.php, usually located in layout/sub
This is not really needed, however. This makes sure that an email starting with something @ ends with something . something has to be written. "Type=Email" that is.
Change:
LUA:
<div class="username-box">
username: <br>
<input type="text" name="username">
</div>
To:
LUA:
<div class="username-box">
Email: <br>
<input type="email" name="username">
</div>
Now we enter engine/function/users.php
Find this:
LUA:
// Checks that username exist in database
function user_exist($username) {
$username = sanitize($username);
if (config('ServerEngine') !== 'OTHIRE')
$data = mysql_select_single("SELECT `id` FROM `accounts` WHERE `name`='$username';");
else
$data = mysql_select_single("SELECT `id` FROM `accounts` WHERE `id`='$username';");
return ($data !== false) ? true : false;
}
Replace with:
LUA:
// Checks that useremail exist in database
// Updated from name -> email
function user_exist($useremail) {
$useremail = sanitize($useremail);
if (config('ServerEngine') !== 'OTHIRE')
$data = mysql_select_single("SELECT `id` FROM `accounts` WHERE `email`='$useremail';");
else
$data = mysql_select_single("SELECT `id` FROM `accounts` WHERE `id`='$useremail';");
return ($data !== false) ? true : false;
}
Find:
LUA:
// Login with a user. (TFS 0.2)
function user_login($username, $password) {
$username = sanitize($username);
$password = sha1($password);
if (config('ServerEngine') !== 'OTHIRE')
$data = mysql_select_single("SELECT `id` FROM accounts WHERE name='$username' AND password='$password';");
else
$data = mysql_select_single("SELECT `id` FROM accounts WHERE id='$username' AND password='$password';");
return ($data !== false) ? $data['id'] : false;
}
Replace with:
LUA:
// Login with a user. (TFS 0.2)
// Updated from name -> email
function user_login($useremail, $password) {
$useremail = sanitize($useremail);
$password = sha1($password);
if (config('ServerEngine') !== 'OTHIRE')
$data = mysql_select_single("SELECT `id` FROM accounts WHERE email='$useremail' AND password='$password';");
else
$data = mysql_select_single("SELECT `id` FROM accounts WHERE id='$useremail' AND password='$password';");
return ($data !== false) ? $data['id'] : false;
}
Find:
LUA:
// Login a user with TFS 0.3 compatibility
function user_login_03($username, $password) {
if (config('salt') === true) {
$username = sanitize($username);
$data = mysql_select_single("SELECT `salt`, `id`, `password`, `name` FROM `accounts` WHERE `name`='$username';");
$salt = $data['salt'];
if (!empty($salt)) $password = sha1($salt.$password);
else $password = sha1($password);
return ($data !== false && $data['name'] == $username && $data['password'] == $password) ? $data['id'] : false;
} else return user_login($username, $password);
}
Replace with:
LUA:
// Login a user with TFS 0.3 compatibility
// Updated from name -> email
function user_login_03($useremail, $password) {
if (config('salt') === true) {
$useremail = sanitize($useremail);
$data = mysql_select_single("SELECT `salt`, `id`, `password`, `email` FROM `accounts` WHERE `email`='$useremail';");
$salt = $data['salt'];
if (!empty($salt)) $password = sha1($salt.$password);
else $password = sha1($password);
return ($data !== false && $data['email'] == $useremail && $data['password'] == $password) ? $data['id'] : false;
} else return user_login($useremail, $password);
}
This should be all you need to do in-order to change the method from using a username to logging in with an email address, I tried using an alternative login method. But it kept denying my request due to a token generated by default of Znote acc so this was a quick solution of my issue I came across.
Hope it helps.