Skip to content

Commit

Permalink
Clippy code
Browse files Browse the repository at this point in the history
  • Loading branch information
EkkoG committed Dec 27, 2023
1 parent 0b805ac commit 1abc7af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/login/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ pub fn scheme() -> String {
else {
"http"
};
return String::from(scheme);
String::from(scheme)
}

21 changes: 13 additions & 8 deletions src/routes/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,32 @@ async fn home(

let mut platforms = Vec::<HashMap::<&str, String>>::new();

let host = req.connection_info().host().to_string();
platforms.push({
let mut map = HashMap::new();
map.insert("name", Github.name());
map.insert("url", Github.login_url(req.connection_info().host().to_string(), state.clone()));
map.insert("url", Github.login_url(host.clone(), state.clone()));
map
});

platforms.push({
let mut map = HashMap::new();
map.insert("name", GitLab.name());
map.insert("url", GitLab.login_url(req.connection_info().host().to_string(), state.clone()));
map.insert("url", GitLab.login_url(host.clone(), state.clone()));
map
});

platforms.push({
let mut map = HashMap::new();
map.insert("name", Google.name());
map.insert("url", Google.login_url(req.connection_info().host().to_string(), state.clone()));
map.insert("url", Google.login_url(host.clone(), state.clone()));
map
});

platforms.push({
let mut map = HashMap::new();
map.insert("name", Microsoft.name());
map.insert("url", Microsoft.login_url(req.connection_info().host().to_string(), state.clone()));
map.insert("url", Microsoft.login_url(host, state.clone()));
map
});

Expand Down Expand Up @@ -92,7 +93,8 @@ async fn login_microsoft_callback(
pool: web::Data<DbPool>,
req: HttpRequest,
) -> Result<HttpResponse, Error> {
let user_info = Microsoft.user_info(req.connection_info().host().to_string(), info.code.clone()).await;
let host = req.connection_info().host().to_string();
let user_info = Microsoft.user_info(host, info.code.clone()).await;
login_callback(info, pool, req, user_info).await
}

Expand All @@ -102,7 +104,8 @@ async fn login_google_callback(
pool: web::Data<DbPool>,
req: HttpRequest,
) -> Result<HttpResponse, Error> {
let user_info = Google.user_info(req.connection_info().host().to_string(), info.code.clone()).await;
let host = req.connection_info().host().to_string();
let user_info = Google.user_info(host, info.code.clone()).await;
login_callback(info, pool, req, user_info).await
}

Expand All @@ -112,7 +115,8 @@ async fn login_github_callback(
pool: web::Data<DbPool>,
req: HttpRequest,
) -> Result<HttpResponse, Error> {
let user_info = Github.user_info(req.connection_info().host().to_string(), info.code.clone()).await;
let host = req.connection_info().host().to_string();
let user_info = Github.user_info(host, info.code.clone()).await;
login_callback(info, pool, req, user_info).await
}

Expand All @@ -122,7 +126,8 @@ async fn login_gitlab_callback(
pool: web::Data<DbPool>,
req: HttpRequest,
) -> Result<HttpResponse, Error> {
let user_info = GitLab.user_info(req.connection_info().host().to_string(), info.code.clone()).await;
let host = req.connection_info().host().to_string();
let user_info = GitLab.user_info(host, info.code.clone()).await;
login_callback(info, pool, req, user_info).await
}

Expand Down

0 comments on commit 1abc7af

Please sign in to comment.