Commit 7c459d39 authored by Julian Sparber's avatar Julian Sparber

accountsettings: use stored identity server

https://gitlab.gnome.org/World/fractal/issues/21
parent 708c5c02
......@@ -101,7 +101,7 @@ pub fn get_email_token(bk: &Backend, identity: String, email: String, client_sec
let url = bk.url(&format!("account/3pid/email/requestToken"), vec![])?;
let attrs = json!({
"id_server": identity,
"id_server": identity[8..],
"client_secret": client_secret,
"email": email,
"send_attempt": "1",
......@@ -130,7 +130,7 @@ pub fn get_phone_token(bk: &Backend, identity: String, phone: String, client_sec
let url = bk.url(&format!("account/3pid/msisdn/requestToken"), vec![])?;
let attrs = json!({
"id_server": identity,
"id_server": identity[8..],
"client_secret": client_secret,
"phone_number": phone,
"country": "",
......@@ -160,7 +160,7 @@ pub fn add_threepid(bk: &Backend, identity: String, client_secret: String, sid:
let url = bk.url(&format!("account/3pid"), vec![])?;
let attrs = json!({
"three_pid_creds": {
"id_server": identity,
"id_server": identity[8..],
"sid": sid,
"client_secret": client_secret
},
......
......@@ -26,7 +26,7 @@ impl AppOp {
pub fn valid_phone_token(&self, sid: Option<String>) {
if let Some(sid) = sid {
let _ = self.backend.send(BKCommand::AddThreePID(String::from("vector.im"), String::from("canitworksandia2"), sid.clone()));
let _ = self.backend.send(BKCommand::AddThreePID(self.identity_url.clone(), String::from("canitworksandia2"), sid.clone()));
}
else {
self.show_error_dialog(String::from("The validation code is not correct."));
......@@ -70,11 +70,13 @@ impl AppOp {
});
let value = entry.clone();
let id_server = self.identity_url.clone();
dialog.connect_response(move |w, r| {
match gtk::ResponseType::from(r) {
gtk::ResponseType::Ok => {
if let Some(token) = value.get_text() {
let _ = backend.send(BKCommand::SubmitPhoneToken(String::from("https://vector.im"), String::from("canitworksandia2"), sid.clone(), token));
// identity_url with https://
let _ = backend.send(BKCommand::SubmitPhoneToken(id_server.clone(), String::from("canitworksandia2"), sid.clone(), token));
}
},
_ => {}
......@@ -93,12 +95,13 @@ impl AppOp {
let flags = gtk::DialogFlags::MODAL | gtk::DialogFlags::DESTROY_WITH_PARENT;
let dialog = gtk::MessageDialog::new(Some(&parent), flags, gtk::MessageType::Error, gtk::ButtonsType::None, &msg);
let backend = self.backend.clone();
let id_server = self.identity_url.clone();
dialog.add_button("Cancel", gtk::ResponseType::Cancel.into());
dialog.add_button("Continue", gtk::ResponseType::Ok.into());
dialog.connect_response(move |w, r| {
match gtk::ResponseType::from(r) {
gtk::ResponseType::Ok => {
let _ = backend.send(BKCommand::AddThreePID(String::from("vector.im"), String::from("tosecretsecret2"), sid.clone()));
let _ = backend.send(BKCommand::AddThreePID(id_server.clone(), String::from("tosecretsecret2"), sid.clone()));
},
_ => {}
}
......
......@@ -150,8 +150,9 @@ impl<'a> Address<'a> {
let action = &self.action;
let entry = &self.entry;
let address = &self.address;
let id_server = &self.op.identity_url;
let backend = &self.op.backend;
self.signal_id = Some(self.button.clone().connect_clicked(clone!(medium, action, entry, address, backend => move |w| {
self.signal_id = Some(self.button.clone().connect_clicked(clone!(id_server, medium, action, entry, address, backend => move |w| {
if w.get_sensitive() && w.is_visible() {
/* get address from entry if we don't have one */
let address = if address.is_none() {
......@@ -184,8 +185,7 @@ impl<'a> Address<'a> {
entry.set_editable(false);
backend.send(
BKCommand::GetTokenEmail(
String::from("vector.im"), address, String::from("tosecretsecret2"))).unwrap();
id_server.clone(), address, String::from("tosecretsecret2"))).unwrap();
},
}
}
......@@ -212,8 +212,7 @@ impl<'a> Address<'a> {
entry.set_editable(false);
backend.send(
BKCommand::GetTokenPhone(
String::from("vector.im"), address, String::from("canitworksandia2"))).unwrap();
id_server.clone(), address, String::from("canitworksandia2"))).unwrap();
},
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment