2018-04-23 12:54:37 +02:00
|
|
|
use heck::CamelCase;
|
2018-06-04 21:57:03 +02:00
|
|
|
use rocket::response::{Redirect, Flash};
|
2018-04-23 12:54:37 +02:00
|
|
|
|
2018-04-23 13:10:15 +02:00
|
|
|
/// Remove non alphanumeric characters and CamelCase a string
|
2018-04-23 12:54:37 +02:00
|
|
|
pub fn make_actor_id(name: String) -> String {
|
2018-04-23 13:10:15 +02:00
|
|
|
name.as_str()
|
|
|
|
.to_camel_case()
|
|
|
|
.to_string()
|
|
|
|
.chars()
|
|
|
|
.filter(|c| c.is_alphanumeric())
|
|
|
|
.collect()
|
2018-04-23 12:54:37 +02:00
|
|
|
}
|
2018-04-23 16:25:39 +02:00
|
|
|
|
2018-06-04 21:57:03 +02:00
|
|
|
pub fn requires_login(message: &str, url: &str) -> Flash<Redirect> {
|
|
|
|
Flash::new(Redirect::to(&format!("/login?m={}", message)), "callback", url)
|
2018-04-23 16:25:39 +02:00
|
|
|
}
|