diff --git a/src/json_api/oauth/authorize.rs b/src/json_api/oauth/authorize.rs index 07be2e9..6ade152 100644 --- a/src/json_api/oauth/authorize.rs +++ b/src/json_api/oauth/authorize.rs @@ -65,12 +65,13 @@ pub async fn authorize_submit( let expires_at = Utc::now().naive_utc() + Duration::minutes(5); if let Err(db_err) = sqlx::query( - "INSERT INTO oauth_auth_codes (code, pid, redirect_uri, expires_at) VALUES ($1, $2, $3, $4)" + "INSERT INTO oauth_auth_codes (code, pid, redirect_uri, expires_at, client_id) VALUES ($1, $2, $3, $4, $5)" ) .bind(&secure_auth_code) .bind(pid) .bind(form_data.redirect_uri) .bind(expires_at) + .bind(form_data.client_id) .execute(pool.inner()) .await { eprintln!("failed to save auth code: {:?}", db_err); diff --git a/src/json_api/oauth/generate_token.rs b/src/json_api/oauth/generate_token.rs index 767e374..091a99f 100644 --- a/src/json_api/oauth/generate_token.rs +++ b/src/json_api/oauth/generate_token.rs @@ -33,8 +33,6 @@ pub struct TokenRequest<'r> { } pub fn verify_nintendo_password(pid: i32, text_password: &str, db_bcrypt_hash: &str) -> bool { - // maple: binder, there's already a function for this, why duplicate code? - // binder: dear maple, with this function i can just hand it a pid, the password from the user and the db_bcrypt_hash and it gives me a true/false value. let mut sha = Sha256::new(); sha.update(bytes_of(&pid)); sha.update(&[0x02, 0x65, 0x43, 0x46]); @@ -54,6 +52,8 @@ pub async fn generate_token( pool: &State, form_data: Form>, ) -> Result, (Status, Json)> { + println!("redirect URI is: {:?}", form_data.redirect_uri); + match form_data.client_id { Some("account") | Some("splatnet") => { let cl_secret: String = CLIENT_SECRET.clone();