getting somewhere

This commit is contained in:
Mashy 2019-07-19 19:46:54 +10:00
parent 51d3c76460
commit 9c45a3fb7a
2 changed files with 13 additions and 4 deletions

View File

@ -15,6 +15,7 @@ const addState = connect(
.then(res => res.json())
.then(data => {
if (!data.success) return errorToast(data.error_message);
console.log(data.response);
ws.connect();
})
.catch(error => errorToast(error));

View File

@ -20,7 +20,7 @@ use payments::{stripe};
pub const TOKEN_HEADER: &str = "x-auth-token";
#[derive(Fail, Debug, Serialize, Deserialize)]
#[derive(Clone, Copy, Fail, Debug, Serialize, Deserialize)]
pub enum MnmlHttpError {
// User Facing Errors
#[fail(display="internal server error")]
@ -67,7 +67,7 @@ impl From<MnmlHttpError> for IronError {
MnmlHttpError::PasswordUnacceptable => (m_err.compat(), status::BadRequest),
MnmlHttpError::InvalidCode => (m_err.compat(), status::Unauthorized),
};
let err_msg = JsonResponse::error("grep".to_string());
let err_msg = JsonResponse::error(m_err.to_string());
let err_out = serde_json::to_string(&err_msg).expect("Failed to encode response");
let content_type = "application/json".parse::<Mime>().expect("Failed to parse content type");
@ -132,7 +132,15 @@ fn token_res(token: String) -> Response {
.max_age(Duration::weeks(1)) // 1 week aligns with db set
.finish();
let mut res = Response::with(status::Ok);
let content_type = "application/json".parse::<Mime>().expect("Failed to parse content type");
let msg = JsonResponse {
response: "success666".to_string(),
success: true,
error_message: "".to_string()
};
let msg_out = serde_json::to_string(&msg).expect("Failed to encode response");
let mut res = Response::with((content_type, status::Ok, msg_out));
res.headers.set(SetCookie(vec![v.to_string()]));
return res;