This commit is contained in:
parent
73ff739c81
commit
8c01e2d5fd
2 changed files with 4 additions and 3 deletions
|
|
@ -65,12 +65,13 @@ pub async fn authorize_submit(
|
||||||
let expires_at = Utc::now().naive_utc() + Duration::minutes(5);
|
let expires_at = Utc::now().naive_utc() + Duration::minutes(5);
|
||||||
|
|
||||||
if let Err(db_err) = sqlx::query(
|
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(&secure_auth_code)
|
||||||
.bind(pid)
|
.bind(pid)
|
||||||
.bind(form_data.redirect_uri)
|
.bind(form_data.redirect_uri)
|
||||||
.bind(expires_at)
|
.bind(expires_at)
|
||||||
|
.bind(form_data.client_id)
|
||||||
.execute(pool.inner())
|
.execute(pool.inner())
|
||||||
.await {
|
.await {
|
||||||
eprintln!("failed to save auth code: {:?}", db_err);
|
eprintln!("failed to save auth code: {:?}", db_err);
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,6 @@ pub struct TokenRequest<'r> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn verify_nintendo_password(pid: i32, text_password: &str, db_bcrypt_hash: &str) -> bool {
|
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();
|
let mut sha = Sha256::new();
|
||||||
sha.update(bytes_of(&pid));
|
sha.update(bytes_of(&pid));
|
||||||
sha.update(&[0x02, 0x65, 0x43, 0x46]);
|
sha.update(&[0x02, 0x65, 0x43, 0x46]);
|
||||||
|
|
@ -54,6 +52,8 @@ pub async fn generate_token(
|
||||||
pool: &State<Pool>,
|
pool: &State<Pool>,
|
||||||
form_data: Form<TokenRequest<'_>>,
|
form_data: Form<TokenRequest<'_>>,
|
||||||
) -> Result<Json<OAuthTokenResponse>, (Status, Json<OAuthErrorResponse>)> {
|
) -> Result<Json<OAuthTokenResponse>, (Status, Json<OAuthErrorResponse>)> {
|
||||||
|
println!("redirect URI is: {:?}", form_data.redirect_uri);
|
||||||
|
|
||||||
match form_data.client_id {
|
match form_data.client_id {
|
||||||
Some("account") | Some("splatnet") => {
|
Some("account") | Some("splatnet") => {
|
||||||
let cl_secret: String = CLIENT_SECRET.clone();
|
let cl_secret: String = CLIENT_SECRET.clone();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue