Disallow blog name which yould result in empty blog name

fix #63
This commit is contained in:
Trinity Pointard 2018-06-19 22:34:59 +02:00
parent 84d58b253d
commit db248701b9

View File

@ -58,7 +58,9 @@ struct NewBlogForm {
fn create(conn: DbConn, data: Form<NewBlogForm>, user: User) -> Redirect { fn create(conn: DbConn, data: Form<NewBlogForm>, user: User) -> Redirect {
let form = data.get(); let form = data.get();
let slug = utils::make_actor_id(form.title.to_string()); let slug = utils::make_actor_id(form.title.to_string());
if slug.len() == 0 {
return Redirect::to("/blogs/new")
}
if Blog::find_local(&*conn, slug.clone()).is_some() { if Blog::find_local(&*conn, slug.clone()).is_some() {
Redirect::to(uri!(new)) Redirect::to(uri!(new))
} else { } else {