Skip to content

Commit 01bf545

Browse files
committed
Removing translation from sources
1 parent 4b22972 commit 01bf545

5 files changed

Lines changed: 35 additions & 83 deletions

File tree

api/AccountUpdate.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ class AccountUpdate
88
{
99
public static function token()
1010
{
11-
echo Account::updateToken($_POST['password'], $_POST['token'] ?? null);
11+
echo json_encode(['token' => Account::updateToken($_POST['password'], $_POST['token'] ?? null)]);
1212
}
1313

1414
public static function email()
1515
{
16-
echo Account::updateEmail($_POST['newMail'], $_POST['password'], $_POST['token'] ?? null);
16+
echo json_encode(['email' => Account::updateEmail($_POST['newMail'], $_POST['password'], $_POST['token'] ?? null)]);
1717
}
1818

1919
public static function verifyEmail($code)
2020
{
21-
echo Account::verifyEmailCode($code);
21+
echo json_encode(['verified_email' => Account::verifyEmailCode($code)]);
2222
}
2323

2424
public static function password()
2525
{
26-
echo Account::updatePassword($_POST['password'], $_POST['newPassword'], $_POST['confirmPassword'], $_POST['token'] ?? null);
26+
echo json_encode(['token' => Account::updatePassword($_POST['password'], $_POST['newPassword'], $_POST['confirmPassword'], $_POST['token'] ?? null)]);
2727
}
2828
}

api/LoginApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class LoginApi
99
public static function login()
1010
{
1111
echo Account::login(
12-
$_POST['username'],
12+
$_POST['email'],
1313
$_POST['password'],
1414
$_POST['keepSession'] ?? false
1515
);

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
},
2424
"require": {
2525
"bubu-framework/router": "^1.0",
26-
"bubu-framework/lang": "^1.0",
2726
"bubu-framework/database": "^1.1",
2827
"vlucas/phpdotenv": "^5.4",
2928
"bubu-framework/email": "^1.0"

composer.lock

Lines changed: 15 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Account.php

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
use Bubu\Database\Database;
55
use Bubu\Http\Session\Session;
6-
use Bubu\Lang\Lang;
76
use Bubu\Mail\MailTemplate;
87

98
class Account
@@ -12,38 +11,33 @@ class Account
1211

1312
/**
1413
* login
15-
* @param string $username
14+
* @param string $email
1615
* @param string $password
1716
* @param bool $keepSession
1817
*
1918
* @return bool|string
2019
*/
21-
public static function login(string $username, string $password, bool $keepSession = false)
20+
public static function login(string $email, string $password, bool $keepSession = false)
2221
{
2322
$dbData = Database::queryBuilder('Users')
2423
->select('id', 'password', 'email_verified_at', 'token')
25-
->where(Database::expr()::eq('username', $username))
24+
->where(Database::expr()::eq('email', $email))
2625
->fetch();
2726

28-
if ($dbData === false || count($dbData) === 0) {
29-
return Lang::get('account-not-found');
30-
} elseif (!password_verify($password, $dbData['password'])) {
31-
return Lang::get('incorrect-password');
32-
} elseif (is_null($dbData['email_verified_at'])) {
33-
return Lang::get('email-not-verified');
34-
} else {
27+
if ($dbData === false || count($dbData) === 0) return 'account_not_found';
28+
elseif (!password_verify($password, $dbData['password'])) return 'wrong_password';
29+
elseif (is_null($dbData['email_verified_at'])) return 'email_not_verified';
30+
else {
3531
Session::set('token', $dbData['token']);
36-
if ($keepSession) {
37-
Session::changeSessionLifetime($_ENV['SESSION_KEEP_CONNECT']);
38-
}
32+
if ($keepSession) Session::changeSessionLifetime($_ENV['SESSION_KEEP_CONNECT']);
3933
return true;
4034
}
4135
}
4236

4337
public static function regexPassword(string $password, string $confim)
4438
{
45-
if (strlen($password) < 10) return Lang::get('password-length');
46-
elseif ($password !== $confim) return Lang::get('not-same-password');
39+
if (strlen($password) < 10) return 'password_too_short';
40+
elseif ($password !== $confim) return 'password_not_match';
4741
else return true;
4842
}
4943

@@ -72,11 +66,8 @@ public static function signup(
7266
->where(Database::expr()::eq('email', $email))
7367
->fetch();
7468

75-
if ($usernameFetch !== false && count($usernameFetch) !== 0) {
76-
return Lang::get('existing-username');
77-
} elseif ($emailFetch !== false && count($emailFetch) !== 0) {
78-
return Lang::get('existing-email');
79-
}
69+
if ($usernameFetch !== false && count($usernameFetch) !== 0) return 'username_already_used';
70+
elseif ($emailFetch !== false && count($emailFetch) !== 0) return 'email_already_used';
8071

8172
$passCheck = self::regexPassword($password, $passwordConfirm);
8273
if ($passCheck !== true) return $passCheck;
@@ -111,7 +102,7 @@ public static function checkPassword(string $password, ?string $tokenPassed): bo
111102

112103
public static function updateToken(string $password, ?string $token): string
113104
{
114-
if (!self::checkPassword($password, $token)) return Lang::get('incorrect-password');
105+
if (!self::checkPassword($password, $token)) return 'wrong_password';
115106

116107
$newToken = bin2hex(random_bytes(30));
117108

@@ -129,7 +120,7 @@ public static function updateToken(string $password, ?string $token): string
129120

130121
public static function updateEmail(string $newMail, string $password, ?string $token)
131122
{
132-
if (!self::checkPassword($password, $token)) return Lang::get('incorrect-password');
123+
if (!self::checkPassword($password, $token)) return 'wrong_password';
133124

134125
$emailCode = bin2hex(random_bytes(10));
135126

@@ -163,7 +154,7 @@ public static function updatePassword(
163154
string $confirm,
164155
?string $token
165156
) {
166-
if (!self::checkPassword($currentPassword, $token)) return Lang::get('incorrect-password');
157+
if (!self::checkPassword($currentPassword, $token)) return 'wrong_password';
167158

168159
$passCheck = self::regexPassword($newPassword, $confirm);
169160
if ($passCheck !== true) return $passCheck;

0 commit comments

Comments
 (0)