mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-21 17:05:16 +00:00
Return keys listing in auth options
This commit is contained in:
@ -4,17 +4,25 @@
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::data::admin::Admin;
|
||||
use crate::data::admin::{Admin, AdminKey};
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct AuthKey {
|
||||
name: String,
|
||||
id: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct AdminAuthOptions {
|
||||
reset_token: bool,
|
||||
keys: Vec<AuthKey>,
|
||||
}
|
||||
|
||||
impl AdminAuthOptions {
|
||||
pub fn new(admin: &Admin) -> Self {
|
||||
pub fn new(admin: &Admin, keys: &Vec<AdminKey>) -> Self {
|
||||
Self {
|
||||
reset_token: admin.reset_token.is_some()
|
||||
reset_token: admin.reset_token.is_some(),
|
||||
keys: keys.iter().map(|k| AuthKey { id: k.id, name: k.name.to_string() }).collect(),
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user