oxide_cli/auth/token.rs
1use std::{fs, path::Path};
2
3use anyhow::{Result, anyhow};
4
5use crate::auth::server::User;
6
7pub fn get_auth_user(auth_path: &Path) -> Result<User> {
8 match fs::read_to_string(auth_path) {
9 Ok(auth_json_str) => {
10 let user: User = serde_json::from_str(&auth_json_str)?;
11 Ok(user)
12 }
13 Err(_) => Err(anyhow!("You are not logged in yet.")),
14 }
15}