Redirect to login where necessary
This commit is contained in:
parent
a3103a9a58
commit
2e2bc46069
|
@ -160,19 +160,30 @@ pub fn home_screen() -> View<G> {
|
|||
#[component(IssueCreate<G>)]
|
||||
pub fn issue_create() -> View<G> {
|
||||
let repo = Signal::new(String::new());
|
||||
let author = Signal::new(String::new());
|
||||
let title = Signal::new(String::new());
|
||||
let desc = Signal::new(String::new());
|
||||
|
||||
let error = Signal::new(false);
|
||||
|
||||
let on_click = cloned!((repo, author, title, desc, error) => move |_| {
|
||||
let current_user = Signal::new(User::default());
|
||||
|
||||
if G::IS_BROWSER {
|
||||
if let Some(user) = local_storage::getItem("token") {
|
||||
let decoded = base64::decode(user).unwrap();
|
||||
let json = unsafe { String::from_utf8_unchecked(decoded) };
|
||||
current_user.set(serde_json::from_str(&json).unwrap());
|
||||
} else {
|
||||
setLocation("/login");
|
||||
}
|
||||
}
|
||||
|
||||
let on_click = cloned!((repo, title, desc, error) => move |_| {
|
||||
let repo = (*repo.get()).trim().to_string();
|
||||
let author = (*author.get()).trim().to_string();
|
||||
let author = current_user.get().username.clone();
|
||||
let title = (*title.get()).trim().to_string();
|
||||
let desc = (*desc.get()).trim().to_string();
|
||||
|
||||
if repo == "" || author == "" || title == "" || desc == "" {
|
||||
if repo == "" || title == "" || desc == "" {
|
||||
error.set(true);
|
||||
return;
|
||||
}
|
||||
|
@ -209,10 +220,6 @@ pub fn issue_create() -> View<G> {
|
|||
// TODO: Fetch a list of repos from gitea or something
|
||||
input(placeholder="karx/bugspray", bind:value=repo)
|
||||
}
|
||||
label {
|
||||
"Your username:"
|
||||
input(placeholder="coolguy123", bind:value=author)
|
||||
}
|
||||
label {
|
||||
"Title:"
|
||||
input(bind:value=title)
|
||||
|
|
Loading…
Reference in a new issue