Skip to content

Commit c086550

Browse files
committed
Account add-on
0 parents  commit c086550

9 files changed

Lines changed: 1084 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
.env

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Account add-on
2+
3+
## Usage
4+
5+
### Available routes
6+
7+
```php
8+
Router::get('/validEmail/:code', 'AccountUpdate#verifyEmail');
9+
10+
11+
Router::post('/api/account/update/email', 'AccountUpdate#email');
12+
13+
Router::post('/api/account/register', 'RegisterApi#register');
14+
15+
Router::post('/api/account/login', 'LoginApi#login');
16+
17+
Router::post('/api/account/update/token', 'AccountUpdate#token');
18+
19+
Router::post('/api/account/update/password', 'AccountUpdate#password');
20+
```

api/AccountUpdate.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Bubu\Account\Api;
4+
5+
use Bubu\Account\Account;
6+
7+
class AccountUpdate
8+
{
9+
public static function token()
10+
{
11+
echo Account::updateToken($_POST['password'], $_POST['token'] ?? null);
12+
}
13+
14+
public static function email()
15+
{
16+
echo Account::updateEmail($_POST['newMail'], $_POST['password'], $_POST['token'] ?? null);
17+
}
18+
19+
public static function verifyEmail($code)
20+
{
21+
echo Account::verifyEmailCode($code);
22+
}
23+
24+
public static function password()
25+
{
26+
echo Account::updatePassword($_POST['password'], $_POST['newPassword'], $_POST['confirmPassword'], $_POST['token'] ?? null);
27+
}
28+
}

api/LoginApi.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Bubu\Account\Api;
4+
5+
use Bubu\Account\Account;
6+
7+
class LoginApi
8+
{
9+
public static function login()
10+
{
11+
echo Account::login(
12+
$_POST['username'],
13+
$_POST['password'],
14+
$_POST['keepSession'] ?? false
15+
);
16+
}
17+
}

api/RegisterApi.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Bubu\Account\Api;
4+
5+
use Bubu\Account\Account;
6+
7+
class RegisterApi
8+
{
9+
public static function register()
10+
{
11+
echo Account::signup(
12+
$_POST['username'],
13+
$_POST['password'],
14+
$_POST['passwordConfirm'],
15+
$_POST['email']
16+
);
17+
}
18+
}

composer.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "bubu-framework/account",
3+
"description": "Bubu-framework's account manager",
4+
"type": "library",
5+
"license": "MIT",
6+
"homepage": "https://github.com/bubu-framework/account",
7+
"authors": [
8+
{
9+
"name": "QuentinBubu",
10+
"email": "QuentinBubu.dev@gmail.com"
11+
}
12+
],
13+
"autoload": {
14+
"psr-4": {
15+
"Bubu\\Account\\": "src/",
16+
"Bubu\\Account\\Api\\": "api/"
17+
}
18+
},
19+
"autoload-dev": {
20+
"psr-4": {
21+
"Bubu\\Account\\Tests\\" : "tests/"
22+
}
23+
},
24+
"require": {
25+
"bubu-framework/router": "^1.0",
26+
"bubu-framework/lang": "^1.0",
27+
"bubu-framework/database": "^1.1",
28+
"vlucas/phpdotenv": "^5.4",
29+
"bubu-framework/email": "^1.0"
30+
}
31+
}

0 commit comments

Comments
 (0)