1
0
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:
2021-05-14 11:12:41 +02:00
parent 3838cf3e03
commit 210dcb9597
6 changed files with 37 additions and 9 deletions

View File

@ -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(),
}
}
}