| 1 | use forge_core::Store; |
| 2 | use forge_core::token::{generate_token, hash_token}; |
| 3 | |
| 4 | pub async fn token_for(store: &Store, user_id: &str, scopes: &[&str]) -> String { |
| 5 | let raw = generate_token(); |
| 6 | let scopes: Vec<String> = scopes.iter().map(|s| (*s).to_owned()).collect(); |
| 7 | store |
| 8 | .create_token(user_id, "test", &hash_token(&raw), &scopes, None) |
| 9 | .await |
| 10 | .expect("token"); |
| 11 | raw |
| 12 | } |
| 13 | |
| 14 | pub fn bearer(raw: &str) -> String { |
| 15 | format!("Bearer {raw}") |
| 16 | } |