formatting
This commit is contained in:
parent
e638075cd1
commit
b9b3347dc2
|
@ -16,8 +16,7 @@ pub struct User {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn user(token: String) -> std::io::Result<User> {
|
pub fn user(token: String) -> std::io::Result<User> {
|
||||||
let resp =
|
let resp = ureq::get("https://tulpa.dev/api/v1/user")
|
||||||
ureq::get("https://tulpa.dev/api/v1/user")
|
|
||||||
.set("Authorization", &format!("bearer {}", token))
|
.set("Authorization", &format!("bearer {}", token))
|
||||||
.call();
|
.call();
|
||||||
if !resp.ok() {
|
if !resp.ok() {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use crate::{MainDatabase, models, schema};
|
use crate::{models, schema, MainDatabase};
|
||||||
|
|
||||||
use color_eyre::eyre::{eyre, Result};
|
use color_eyre::eyre::{eyre, Result};
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
|
use hmac::{Hmac, NewMac};
|
||||||
use jwt::{SignWithKey, VerifyWithKey};
|
use jwt::{SignWithKey, VerifyWithKey};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use std::env;
|
|
||||||
use hmac::{Hmac, NewMac};
|
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref SECRET: String = env::var("JWT_SECRET")
|
pub static ref SECRET: String = env::var("JWT_SECRET")
|
||||||
|
@ -15,7 +15,6 @@ lazy_static! {
|
||||||
.to_string();
|
.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
pub fn make(user_id: uuid::Uuid, token_id: uuid::Uuid) -> Result<String> {
|
pub fn make(user_id: uuid::Uuid, token_id: uuid::Uuid) -> Result<String> {
|
||||||
let key: Hmac<Sha256> = Hmac::new_varkey(&*SECRET.as_bytes()).unwrap();
|
let key: Hmac<Sha256> = Hmac::new_varkey(&*SECRET.as_bytes()).unwrap();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::schema::{gitea_tokens, users, tokens};
|
use crate::schema::{gitea_tokens, tokens, users};
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -26,7 +26,7 @@ pub struct User {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Insertable)]
|
#[derive(Insertable)]
|
||||||
#[table_name="gitea_tokens"]
|
#[table_name = "gitea_tokens"]
|
||||||
pub struct NewGiteaToken {
|
pub struct NewGiteaToken {
|
||||||
pub user_id: Uuid,
|
pub user_id: Uuid,
|
||||||
pub access_token: String,
|
pub access_token: String,
|
||||||
|
@ -44,7 +44,7 @@ pub struct GiteaToken {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Insertable)]
|
#[derive(Insertable)]
|
||||||
#[table_name="tokens"]
|
#[table_name = "tokens"]
|
||||||
pub struct NewToken {
|
pub struct NewToken {
|
||||||
pub user_id: Uuid,
|
pub user_id: Uuid,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue