Skip to content

Commit

Permalink
Fix hashing and improve logging in verify_all_records function
Browse files Browse the repository at this point in the history
  • Loading branch information
LimesKey committed Oct 17, 2024
1 parent 62df840 commit b92bcba
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ async fn process_api_payload(
"{}{}{}{}",
slack.slack_id, slack.username, slack.eligibility, slack_oauth.client_secret
);
console_log!("First Secret {}", &combined_secret);

temp_response.hashed_secret = hash_secret(&combined_secret);
}
Expand Down Expand Up @@ -472,26 +471,24 @@ async fn verify_all_records(
jasper_api: &String,
) {
for record in records {
let otp_secret = record.fields.otp;
let eligibility = record.fields.eligibility;
let slack_id = record.fields.slack_id;
let slack_username = record.fields.slack_username;
let otp_secret = &record.fields.otp;
let eligibility = &record.fields.eligibility;
let slack_id = &record.fields.slack_id;
let slack_username = &record.fields.slack_username;

let secret = format!(
"{}{}{}{}",
slack_id, slack_username, eligibility, slack_oauth.client_secret
&slack_id, &slack_username, &eligibility, &slack_oauth.client_secret
);

let hashed_secret = hash_secret(&secret);

let client = Client::new();
let bearer_token = jasper_api;

console_log!("Second Secret {}", &secret);

let json_body = json!({
"recordId": record.id,
"authenticated": (hashed_secret == otp_secret).to_string(),
"authenticated": (hashed_secret == *otp_secret).to_string(),
});

let response = client
Expand All @@ -503,7 +500,7 @@ async fn verify_all_records(
.unwrap();

if response.status().is_success() {
console_log!("Record {} verification successful", record.id);
console_log!("Record num.{} verification successful for {}", record.id, &record.fields.slack_username);
} else {
console_log!(
"Record {} verification failed with status: {}",
Expand Down

0 comments on commit b92bcba

Please sign in to comment.