mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-30 13:04:13 +00:00
implement IMPORT_PEM apply
This commit is contained in:
parent
67ab5bb57e
commit
867a02a191
@ -122,10 +122,16 @@ impl Gemini {
|
|||||||
profile
|
profile
|
||||||
.identity
|
.identity
|
||||||
.gemini
|
.gemini
|
||||||
.create(None, &widget.form.name.value().unwrap())
|
.make(None, &widget.form.name.value().unwrap())
|
||||||
.unwrap(), // @TODO handle result,
|
.unwrap(),
|
||||||
|
),
|
||||||
|
Value::IMPORT_PEM => Some(
|
||||||
|
profile
|
||||||
|
.identity
|
||||||
|
.gemini
|
||||||
|
.add(&widget.form.file.pem.take().unwrap())
|
||||||
|
.unwrap(),
|
||||||
),
|
),
|
||||||
Value::IMPORT_PEM => Some(0), // @TODO
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Apply
|
// Apply
|
||||||
|
@ -40,15 +40,15 @@ impl Form {
|
|||||||
let file = file.clone();
|
let file = file.clone();
|
||||||
let name = name.clone();
|
let name = name.clone();
|
||||||
let update = action.update.clone();
|
let update = action.update.clone();
|
||||||
move |key| {
|
move |item| {
|
||||||
// Change name entry visibility
|
// Change name entry visibility
|
||||||
name.show(match key {
|
name.show(match item {
|
||||||
Value::GENERATE_NEW_AUTH => true,
|
Value::GENERATE_NEW_AUTH => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Change file choose button visibility
|
// Change file choose button visibility
|
||||||
file.show(match key {
|
file.show(match item {
|
||||||
Value::IMPORT_PEM => true,
|
Value::IMPORT_PEM => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
});
|
});
|
||||||
@ -70,7 +70,7 @@ impl Form {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
/// Validate form in current set
|
/// Validate `Self` components match current selection
|
||||||
pub fn is_valid(&self) -> bool {
|
pub fn is_valid(&self) -> bool {
|
||||||
match self.list.selected() {
|
match self.list.selected() {
|
||||||
Value::GENERATE_NEW_AUTH => self.name.is_valid(),
|
Value::GENERATE_NEW_AUTH => self.name.is_valid(),
|
||||||
|
@ -12,7 +12,7 @@ const LABEL: &str = "Choose file..";
|
|||||||
const MARGIN: i32 = 8;
|
const MARGIN: i32 = 8;
|
||||||
|
|
||||||
pub struct File {
|
pub struct File {
|
||||||
pem: Rc<RefCell<Option<GString>>>,
|
pub pem: Rc<RefCell<Option<GString>>>,
|
||||||
pub gobject: Button,
|
pub gobject: Button,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ impl Identity {
|
|||||||
if let Some(id) = self.gemini.auth.memory.match_priority(request) {
|
if let Some(id) = self.gemini.auth.memory.match_priority(request) {
|
||||||
match self.gemini.memory.get(id) {
|
match self.gemini.memory.get(id) {
|
||||||
Ok(pem) => return Some(pem),
|
Ok(pem) => return Some(pem),
|
||||||
Err(_) => todo!(),
|
Err(reason) => todo!("{:?}", reason),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
@ -54,9 +54,21 @@ impl Gemini {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
|
||||||
/// Create new record
|
/// Add new record to database, update memory index
|
||||||
/// * return new `profile_identity_gemini_id` on success
|
/// * return new `profile_identity_gemini_id` on success
|
||||||
pub fn create(&self, time: Option<(DateTime, DateTime)>, name: &str) -> Result<i64, Error> {
|
pub fn add(&self, pem: &str) -> Result<i64, Error> {
|
||||||
|
match self.database.add(pem) {
|
||||||
|
Ok(profile_identity_gemini_id) => {
|
||||||
|
self.index()?;
|
||||||
|
Ok(profile_identity_gemini_id)
|
||||||
|
}
|
||||||
|
Err(reason) => Err(Error::DatabaseRecordCreate(reason)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Generate new certificate and insert record to DB, update memory index
|
||||||
|
/// * return new `profile_identity_gemini_id` on success
|
||||||
|
pub fn make(&self, time: Option<(DateTime, DateTime)>, name: &str) -> Result<i64, Error> {
|
||||||
// Generate new certificate
|
// Generate new certificate
|
||||||
match certificate::generate(
|
match certificate::generate(
|
||||||
match time {
|
match time {
|
||||||
@ -68,13 +80,7 @@ impl Gemini {
|
|||||||
},
|
},
|
||||||
name,
|
name,
|
||||||
) {
|
) {
|
||||||
Ok(pem) => match self.database.add(&pem) {
|
Ok(pem) => self.add(&pem),
|
||||||
Ok(profile_identity_gemini_id) => {
|
|
||||||
self.index()?;
|
|
||||||
Ok(profile_identity_gemini_id)
|
|
||||||
}
|
|
||||||
Err(reason) => Err(Error::DatabaseRecordCreate(reason)),
|
|
||||||
},
|
|
||||||
Err(reason) => Err(Error::Certificate(reason)),
|
Err(reason) => Err(Error::Certificate(reason)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user