- Notifications
You must be signed in to change notification settings - Fork352
Dan set user#697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Dan set user#697
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -5,6 +5,7 @@ use rocket::request::{FromRequest, Outcome, Request}; | ||||||
| use rocket::State; | ||||||
| use sqlx::PgPool; | ||||||
| use crate::models::User; | ||||||
| use crate::{Clusters, Context}; | ||||||
| pub fn default_database_url() -> String { | ||||||
| @@ -46,17 +47,31 @@ impl<'r> FromRequest<'r> for Cluster { | ||||||
| None => -1, | ||||||
| }; | ||||||
| let user_id: i64 = match cookies.get_private("user_id") { | ||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Also we are setting this object in our closed source code, you don't need to fetch the cookie here. The cookie won't provide enough user information once we start adding more, e.g. email. | ||||||
| Some(user_id) => match user_id.value().parse::<i64>() { | ||||||
| Ok(user_id) => user_id, | ||||||
| Err(_) => -1, | ||||||
| }, | ||||||
| None => -1, | ||||||
| }; | ||||||
| let clusters_shared_state = match request.guard::<&State<Clusters>>().await { | ||||||
| Outcome::Success(pool) => pool, | ||||||
| _ => return Outcome::Forward(()), | ||||||
| }; | ||||||
| let pool =clusters_shared_state.get(cluster_id); | ||||||
| let context = Context { | ||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Isn't | ||||||
| user: User { | ||||||
| id: user_id, | ||||||
| email: "".to_string(), | ||||||
| }, | ||||||
| cluster: clusters_shared_state.get_context(cluster_id).cluster, | ||||||
| visible_clusters: clusters_shared_state | ||||||
| .get_context(cluster_id) | ||||||
| .visible_clusters, | ||||||
| }; | ||||||
| Outcome::Success(Cluster { pool, context }) | ||||||