WIP
continuous-integration/drone/push Build is failing Details

d_yanis 1 year ago
parent b20a78e5dd
commit f5b1bda036

@ -116,7 +116,6 @@ function EditorView({
courtType,
}: EditorViewProps) {
const isInGuestMode = id == -1
const [titleStyle, setTitleStyle] = useState<CSSProperties>({})
const [content, setContent, saveState] = useContentState(
initialContent,

@ -47,8 +47,9 @@ function ContentAccountSettings({user} : {user : User}) {
<dl>
<dt>Nom d'utilisateur</dt>
{/* Utilisez la valeur de l'état et la fonction onChange */}
<dd><input type="text" value={username} onChange={handleUsernameChange} /></dd>
<dd><input type="text" value={username} id="username" name="username" onChange={handleUsernameChange} /></dd>
</dl>
<input type="submit" value="Update"/>
</form>
);
}

@ -8,6 +8,7 @@ require "../../src/index-utils.php";
use IQBall\Api\API;
use IQBall\Api\Controller\APIAuthController;
use IQBall\Api\Controller\APITacticController;
use IQBall\Api\Controller\APIUserController;
use IQBall\App\Session\PhpSessionHandle;
use IQBall\Core\Action;
use IQBall\Core\Connection;
@ -25,6 +26,10 @@ function getAuthController(): APIAuthController {
return new APIAuthController(new AuthModel(new AccountGateway(new Connection(get_database()))));
}
function getAPIUserController() : APIUserController {
return new APIUserController(new AuthModel(new AccountGateway(new Connection(get_database()))));
}
function getRoutes(): AltoRouter {
$router = new AltoRouter();
$router->setBasePath(get_public_path(__DIR__));
@ -32,7 +37,7 @@ function getRoutes(): AltoRouter {
$router->map("POST", "/auth", Action::noAuth(fn() => getAuthController()->authorize()));
$router->map("POST", "/tactic/[i:id]/edit/name", Action::auth(fn(int $id, Account $acc) => getTacticController()->updateName($id, $acc)));
$router->map("POST", "/tactic/[i:id]/save", Action::auth(fn(int $id, Account $acc) => getTacticController()->saveContent($id, $acc)));
$router->map("POST", "/user/username/[name]", Action::auth(fn(string $username, Account $acc) => getUserController()->))
// $router->map("POST", "/user/username", Action::auth(fn(Account $acc) => getAPIUserController()->changeUsername($acc)));
return $router;
}

@ -85,6 +85,7 @@ function getRoutes(): AltoRouter {
$ar->map("GET", "/home", Action::auth(fn(SessionHandle $s) => getUserController()->home($s)));
$ar->map("GET", "/settings", Action::auth(fn(SessionHandle $s) => getUserController()->settings($s)));
$ar->map("GET", "/disconnect", Action::auth(fn(MutableSessionHandle $s) => getUserController()->disconnect($s)));
$ar->map("POST", "/user/profil", Action::auth(fn(SessionHandle $s) => getUserController()->updateProfil($_POST, $s)));
//tactic-related

@ -2,8 +2,13 @@
namespace IQBall\Api\Controller;
use IQBall\App\Control;
use IQBall\Core\Model\AuthModel;
use IQBall\Core\Data\Account;
use IQBall\Core\Http\HttpCodes;
use IQBall\Core\Http\HttpRequest;
use IQBall\Core\Http\HttpResponse;
use IQBall\Core\Validation\Validators;
class APIUserController {
private AuthModel $model;
@ -12,8 +17,14 @@ class APIUserController {
$this->model = $model;
}
public function changeUsername(Account $acc, string $newUsername,) {
$this->model->changeUsername($acc->getUser()->getId(), $newUsername);
public function changeUsername(Account $acc) {
return Control::runChecked([
"username" => [Validators::name()]
], function(HttpRequest $request) use ($acc) {
$this->model->changeUsername($acc->getUser()->getId(), $request["username"]);
return HttpResponse::fromCode(HttpCodes::OK);
});
}
}

@ -64,4 +64,8 @@ class UserController {
return HttpResponse::redirect("/");
}
public function updateProfil(array $request, SessionHandle $s) {
}
}

Loading…
Cancel
Save