diff options
Diffstat (limited to 'src/handlers.rs')
-rw-r--r-- | src/handlers.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/handlers.rs b/src/handlers.rs index 25b7098..4a1edcc 100644 --- a/src/handlers.rs +++ b/src/handlers.rs | |||
@@ -152,6 +152,17 @@ pub async fn authenticate_user( | |||
152 | return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); | 152 | return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); |
153 | } | 153 | } |
154 | 154 | ||
155 | // We're using this as the validator | ||
156 | // I hate myself | ||
157 | if let Err(_) = DecodingKey::from_rsa_pem(request.public_key.as_bytes()) { | ||
158 | let res_json = warp::reply::json(&GradeCoinResponse { | ||
159 | res: ResponseType::Error, | ||
160 | message: "The supplied RSA public key is not in valid PEM format".to_owned(), | ||
161 | }); | ||
162 | |||
163 | return Ok(warp::reply::with_status(res_json, StatusCode::BAD_REQUEST)); | ||
164 | } | ||
165 | |||
155 | let fingerprint = format!("{:x}", Sha256::digest(&request.public_key.as_bytes())); | 166 | let fingerprint = format!("{:x}", Sha256::digest(&request.public_key.as_bytes())); |
156 | 167 | ||
157 | let new_user = User { | 168 | let new_user = User { |