Update wasm for base64 encoded invite
This commit is contained in:
parent
0a12b0fc52
commit
0e28602812
|
@ -374,7 +374,6 @@ mod tests {
|
|||
|
||||
// Test Open Invite and get response
|
||||
let invite_response_str = body_to_string(invite_response).await;
|
||||
println!("Base64 invite {:?}", invite_response_str);
|
||||
let response_data: lox_utils::Invite = serde_json::from_str(&invite_response_str).unwrap();
|
||||
let token = match lox_utils::validate(&response_data.invite) {
|
||||
Ok(token) => token,
|
||||
|
|
|
@ -199,7 +199,7 @@ function request_open_invite() {
|
|||
return new Promise((fulfill, reject) => {
|
||||
loxServerPostRequest("/invite", null).then((response) => {
|
||||
console.log("Got invitation token: " + response.invite);
|
||||
fulfill(response.invite);
|
||||
fulfill(JSON.stringify(response));
|
||||
return;
|
||||
}).catch(() => {
|
||||
console.log("Error requesting open invite from Lox server");
|
||||
|
|
|
@ -29,9 +29,13 @@ pub fn set_panic_hook() {
|
|||
// Receives an invite and prepares an open_invite request, returning the
|
||||
// Request and State
|
||||
#[wasm_bindgen]
|
||||
pub fn open_invite(invite: &[u8]) -> Result<String, JsValue> {
|
||||
log(&format!("Using invite: {:?}", invite));
|
||||
let token = match lox_utils::validate(invite) {
|
||||
pub fn open_invite(base64_invite: String) -> Result<String, JsValue> {
|
||||
log(&format!("Using invite: {:?}", base64_invite));
|
||||
let invite: lox_utils::Invite = match serde_json::from_str(&base64_invite) {
|
||||
Ok(invite) => invite,
|
||||
Err(e) => return Err(JsValue::from(e.to_string())),
|
||||
};
|
||||
let token = match lox_utils::validate(&invite.invite) {
|
||||
Ok(token) => token,
|
||||
Err(e) => return Err(JsValue::from(e.to_string())),
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue