mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 03:32:15 +00:00
frontend: Remove some unwraps
This commit is contained in:
@@ -1,8 +1,5 @@
|
|||||||
{% extends "layouts/default.html" %}
|
{% extends "layouts/default.html" %}
|
||||||
|
|
||||||
{% block imports %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<style>
|
<style>
|
||||||
li.collection-list-item {
|
li.collection-list-item {
|
||||||
|
|||||||
@@ -68,12 +68,12 @@ async fn route_calendar<C: CalendarStore + ?Sized>(
|
|||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
store: Data<C>,
|
store: Data<C>,
|
||||||
_user: User,
|
_user: User,
|
||||||
) -> impl Responder {
|
) -> Result<impl Responder, rustical_store::Error> {
|
||||||
let (owner, cal_id) = path.into_inner();
|
let (owner, cal_id) = path.into_inner();
|
||||||
CalendarPage {
|
Ok(CalendarPage {
|
||||||
owner: owner.to_owned(),
|
owner: owner.to_owned(),
|
||||||
calendar: store.get_calendar(&owner, &cal_id).await.unwrap(),
|
calendar: store.get_calendar(&owner, &cal_id).await?,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
@@ -87,12 +87,12 @@ async fn route_addressbook<AS: AddressbookStore + ?Sized>(
|
|||||||
path: Path<(String, String)>,
|
path: Path<(String, String)>,
|
||||||
store: Data<AS>,
|
store: Data<AS>,
|
||||||
_user: User,
|
_user: User,
|
||||||
) -> impl Responder {
|
) -> Result<impl Responder, rustical_store::Error> {
|
||||||
let (owner, addrbook_id) = path.into_inner();
|
let (owner, addrbook_id) = path.into_inner();
|
||||||
AddressbookPage {
|
Ok(AddressbookPage {
|
||||||
owner: owner.to_owned(),
|
owner: owner.to_owned(),
|
||||||
addressbook: store.get_addressbook(&owner, &addrbook_id).await.unwrap(),
|
addressbook: store.get_addressbook(&owner, &addrbook_id).await?,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn route_root(user: Option<User>, req: HttpRequest) -> impl Responder {
|
async fn route_root(user: Option<User>, req: HttpRequest) -> impl Responder {
|
||||||
@@ -113,7 +113,6 @@ fn unauthorized_handler<B>(res: ServiceResponse<B>) -> actix_web::Result<ErrorHa
|
|||||||
let (req, _) = res.into_parts();
|
let (req, _) = res.into_parts();
|
||||||
let login_url = req.url_for_static("frontend_login").unwrap().to_string();
|
let login_url = req.url_for_static("frontend_login").unwrap().to_string();
|
||||||
|
|
||||||
// let response = Redirect::to(login_url).respond_to(&req);
|
|
||||||
let response = HttpResponse::Unauthorized().body(format!(
|
let response = HttpResponse::Unauthorized().body(format!(
|
||||||
r#"<!Doctype html>
|
r#"<!Doctype html>
|
||||||
<html>
|
<html>
|
||||||
|
|||||||
Reference in New Issue
Block a user