34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
use peach_lib::config_manager;
|
|
use rouille::{post_input, try_or_400, Request, Response};
|
|
|
|
// HELPER AND ROUTES FOR /settings/admin/add
|
|
|
|
/// Parse an `admin_id` from the submitted form, save it to file
|
|
/// (`/var/lib/peachcloud/config.yml`) and redirect to the administrator
|
|
/// configuration URL.
|
|
pub fn handle_form(request: &Request) -> Response {
|
|
// query the request body for form data
|
|
// return a 400 error if the admin_id field is missing
|
|
let data = try_or_400!(post_input!(request, {
|
|
// the public key of a desired administrator
|
|
ssb_id: String,
|
|
}));
|
|
|
|
// save submitted admin id to file
|
|
let _result = config_manager::add_ssb_admin_id(&data.ssb_id);
|
|
|
|
// TODO: match on result and define flash message accordingly
|
|
// then send the redirect response
|
|
|
|
// redirect to the configure admin page
|
|
// TODO: add flash message
|
|
Response::redirect_303("/settings/admin/configure")
|
|
}
|
|
|
|
/*
|
|
match result {
|
|
Ok(_) => Flash::success(Redirect::to(url), "Added SSB administrator"),
|
|
Err(e) => Flash::error(Redirect::to(url), format!("Failed to add new admin: {}", e)),
|
|
}
|
|
*/
|