trying to port web app starter from PHP

This commit is contained in:
udo
2026-04-19 09:38:23 +00:00
parent 46d98a092f
commit be514d63d6
546 changed files with 76910 additions and 2807 deletions
@@ -0,0 +1,27 @@
#load "../../lib/app.uce"
RENDER(Request& context)
{
starter_boot(context);
context.var["starter"]["page_title"] = "Login";
DTree result;
if(context.params["REQUEST_METHOD"] == "POST")
{
result = starter_user_sign_in(context.post["email"], context.post["password"], context);
if(result["result"].to_string() != "")
{
starter_redirect("account/profile", context);
return;
}
}
<>
<h1>Login</h1>
<? if(result["message"].to_string() != "") { ?><div class="banner error"><?= result["message"].to_string() ?></div><? } ?>
<form method="post">
<label>Email: <input type="email" name="email" required></label><br>
<label>Password: <input type="password" name="password" required></label><br>
<button type="submit">Login</button>
</form>
<p><a href="<?= starter_link("account/register", context) ?>">Register</a></p>
</>
}
@@ -0,0 +1,8 @@
#load "../../lib/app.uce"
RENDER(Request& context)
{
starter_boot(context);
starter_user_logout(context);
starter_redirect("account/login", context);
}
@@ -0,0 +1,26 @@
#load "../../lib/app.uce"
RENDER(Request& context)
{
starter_boot(context);
if(!starter_is_signed_in(context))
{
starter_redirect("account/login", context);
return;
}
context.var["starter"]["page_title"] = "Profile";
DTree user = starter_current_user(context);
String roles = "";
user["roles"].each([&](DTree role, String key) {
if(roles != "")
roles += ", ";
roles += role.to_string();
});
<>
<h1>Profile</h1>
<p>Email: <?= user["email"].to_string() ?></p>
<p>Roles: <?= roles ?></p>
<p>Created: <?= date("%Y-%m-%dT%H:%M:%S", int_val(user["created"].to_string())) ?></p>
<p><a href="<?= starter_link("account/logout", context) ?>">Logout</a></p>
</>
}
@@ -0,0 +1,21 @@
#load "../../lib/app.uce"
RENDER(Request& context)
{
starter_boot(context);
context.var["starter"]["page_title"] = "Register";
DTree result;
if(context.params["REQUEST_METHOD"] == "POST")
result = starter_user_create(context.post["email"], context.post["password"], context);
<>
<h1>Register</h1>
<? if(result["result"].to_string() != "") { ?><div class="banner success">Registration successful. <a href="<?= starter_link("account/login", context) ?>">Log in</a></div><? } ?>
<? if(result["message"].to_string() != "" && result["result"].to_string() == "") { ?><div class="banner error"><?= result["message"].to_string() ?></div><? } ?>
<form method="post">
<label>Email: <input type="email" name="email" required></label><br>
<label>Password: <input type="password" name="password" required></label><br>
<button type="submit">Register</button>
</form>
</>
}