Can update user information
This commit is contained in:
parent
91817bd2a4
commit
65dac1e923
@ -138,4 +138,33 @@ pub async fn create_user(user: CurrentUser, clients: web::Data<ClientManager>) -
|
||||
u: Default::default(),
|
||||
clients: clients.cloned(),
|
||||
}.render().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct EditUserQuery {
|
||||
id: UserID,
|
||||
}
|
||||
|
||||
pub async fn edit_user(user: CurrentUser,
|
||||
clients: web::Data<ClientManager>,
|
||||
users: web::Data<Addr<UsersActor>>,
|
||||
query: web::Query<EditUserQuery>,
|
||||
) -> impl Responder {
|
||||
let edited_account = users.send(users_actor::GetUserRequest(query.0.id))
|
||||
.await.unwrap().0;
|
||||
|
||||
|
||||
HttpResponse::Ok().body(EditUserTemplate {
|
||||
_parent: BaseSettingsPage::get(
|
||||
"Edit user account",
|
||||
user.deref(),
|
||||
match edited_account.is_none() {
|
||||
true => Some("Could not find requested user!".to_string()),
|
||||
false => None
|
||||
},
|
||||
None,
|
||||
),
|
||||
u: edited_account.unwrap_or_default(),
|
||||
clients: clients.cloned(),
|
||||
}.render().unwrap())
|
||||
}
|
||||
|
@ -118,6 +118,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.route("/admin/users", web::get().to(admin_controller::users_route))
|
||||
.route("/admin/users", web::post().to(admin_controller::users_route))
|
||||
.route("/admin/create_user", web::get().to(admin_controller::create_user))
|
||||
.route("/admin/edit_user", web::get().to(admin_controller::edit_user))
|
||||
|
||||
// Admin API
|
||||
.route("/admin/api/find_username", web::post().to(admin_api::find_username))
|
||||
|
@ -26,7 +26,10 @@
|
||||
<td>{{ u.email }}</td>
|
||||
<td>{% if u.admin %}Admin{% else %}Regular user{% endif %}</td>
|
||||
<td>{% if u.enabled %}Enabled{% else %}Disabled{% endif %}</td>
|
||||
<td>Edit Delete</td>
|
||||
<td>
|
||||
<a href="/admin/edit_user?id={{ u.uid }}">Edit</a>
|
||||
Delete
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
Loading…
Reference in New Issue
Block a user