rename LoginInfo::Token to Application

This commit is contained in:
Cyborus 2024-06-03 13:08:59 -04:00
parent 3ff6a86e8e
commit 349c6ad0d6
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View file

@ -58,7 +58,7 @@ impl AuthCommand {
if keys.hosts.get(&user).is_none() {
keys.hosts.insert(
host,
crate::keys::LoginInfo::Token {
crate::keys::LoginInfo::Application {
name: user,
token: key,
},

View file

@ -67,7 +67,7 @@ impl KeyInfo {
#[derive(serde::Serialize, serde::Deserialize, Clone)]
#[serde(tag = "type")]
pub enum LoginInfo {
Token {
Application {
name: String,
token: String,
},
@ -82,14 +82,14 @@ pub enum LoginInfo {
impl LoginInfo {
pub fn username(&self) -> &str {
match self {
LoginInfo::Token { name, .. } => name,
LoginInfo::Application { name, .. } => name,
LoginInfo::OAuth { name, .. } => name,
}
}
pub async fn api_for(&mut self, url: &Url) -> eyre::Result<forgejo_api::Forgejo> {
match self {
LoginInfo::Token { token, .. } => {
LoginInfo::Application { token, .. } => {
let api = forgejo_api::Forgejo::new(forgejo_api::Auth::Token(token), url.clone())?;
Ok(api)
}