This commit is contained in:
2023-10-04 23:48:12 +03:00
parent 1ca5f4e521
commit 718cdb54f9
22 changed files with 262 additions and 263 deletions
+12 -17
View File
@@ -4,23 +4,29 @@ namespace Lucent\Http\Controller;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Lucent\Account\Auth;
use Lucent\Account\AuthService;
use Lucent\Svelte\Svelte;
use Throwable;
use function Lucent\Response\fail;
use function Lucent\Response\ok;
use function Lucent\Svelte\svelte;
class AccountController extends Controller
{
public function __construct(
public Svelte $svelte,
public AuthService $authService,
)
{
}
public function profile()
{
return svelte(
return $this->svelte->render(
layout: "account",
view: "profile",
title: "Profile",
data: []
);
}
@@ -28,23 +34,12 @@ class AccountController extends Controller
{
try {
(new Auth)->updateName(session("user.id"), $request->input("name"));
} catch (\Throwable $th) {
$this->authService->updateName($request->input("name"));
} catch (Throwable $th) {
return fail($th);
}
return ok();
}
public function updateEmail(Request $request)
{
try {
(new Auth)->updateEmail(session("user.id"), $request->input("email"));
} catch (\Throwable $th) {
return fail($th);
}
return ok();
}
}